-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to debug the compilation error "Cannot extract value from singleton.ops.impl.OpMacro"? #152
Comments
The full context of this error is displayed in the CI output: https://github.com/tribbloid/shapesafe/runs/925426505?check_suite_focus=true#step:4:76 |
From what I see in the error you have an operation |
That's the obvious part, the no-so-obvious part is why Also, the |
The
The type definition on the root level is |
Can you please do the following:
Afterwords, go back to the original configuration. The log is huge and will slow you down. |
Thanks a lot, here is the relevant part of the log (logging level set to --info):
Hope it could be useful |
@soronpo Thanks a lot for your attention, did you observe anything strange in the log? |
Thanks for the reminder. Forgot to respond. From the looks of it, indeed it's not singleton-ops territory. From the getgo the |
It looks like the
|
Try with |
(I guess this is more suitable to be posted on scalabug issue tracker, bu here you go)
|
Maybe it's a compiler flag. Maybe some instability as some improper macro use. |
agreed, after spending some time playing with the compiler it appears that all implicit inference from symbols like
I got a similar error:
This in the end can be traced back to a alleged compiler bug: Of which the cause is still inconclusive. Let me try some other tricks before figuring out a way to bypass it |
No it was not relevant, original ticket (scala/scala#5836) merely shows a feature being removed due to conflict with other behaviour of the compiler. So I end up debugging it in runtime using reflection:
Which gives the proper type argument you have observed: PolyType(List(TypeName("S")), ClassInfoType(List(TypeRef(ThisType(scala), TypeName("AnyRef"), List()), TypeRef(ThisType(edu.umontreal.kotlingrad.shapesafe.m.arity.Arity), edu.umontreal.kotlingrad.shapesafe.m.arity.Arity.Const, List(TypeRef(NoPrefix, TypeName("S"), List())))), Scope(TermName("singleton"), TermName("singleton "), termNames.CONSTRUCTOR, TermName("number")), edu.umontreal.kotlingrad.shapesafe.m.arity.Arity.FromLiteral)) But it is before the resolution! Using the
gives the refined type: FoldableConstantType(Constant(6)) Of course, I was conducting the experiment in runtime universe, and the compile-time may follow an entirely different path. Regardless, do you think the above |
Can you post a print of the |
yes sir,
BTW
|
If you will be able to minimize this, it would help a lot. Can you please provide the following:
|
At your service:
The following 2 phrases doesn't compile:
so I twisted them a bit. |
the result is also displayed in the CI: |
The 6 type value isn't making its way into singleton-ops, so it looks like the typetag is inspecting the wrong thing. trait FromtLiteral[T] {
type Out = T
}
val fl : FromLiteral[6] = ??? Then you |
@soronpo sorry for the slow reply, I just tried your example and it reproduces the error:
if compiled with either scala 2.12.11 or 2.13.3, the compile reports:
|
If you like to play with it, voila: https://scastie.scala-lang.org/tribbloid/3Ijg2dSLRcmiiNrXnSf4hg |
You need |
@soronpo I'm so sorry, after 2 weeks I no longer remember how shapeless works 🤦 I think I've finally isolate the problem, all caused by
https://scastie.scala-lang.org/tribbloid/yRXvkpWWRiWAyGHzpI9g1Q/1 Scalac was known for fumbling on this.type inference. This issue may be one instance of such fumbling and may won't be fixed without some major compiler overhaul. Regardless, the above case may worth further investigation to be 100% sure of the cause For the moment I'll just replace the abstract type with an F-bounded type parameter to circumvent it. Thank you so much for your instructions! |
Hi @fthomas @soronpo Thanks a lot for the great work, I'm one of the supporting developer of the deep learning library kotlingrad. When we try to integrate singleton-ops for the project on some tensor operations, we encounter some strange compiler behaviours that are hard to isolate or simplify, so we have to post a link to our repository in case others want to reproduce, sorry.
In one of our test cases: https://github.com/tribbloid/shapesafe/blob/59405baedc9048a9cac1fbf2bb7708c917266a6e/core/src/test/scala/edu/umontreal/kotlingrad/shapesafe/core/tensor/DoubleVectorSpec.scala#L167
The compiler / macro misbehave on 2 apparently equivalent code blocks:
These are the compilation errors:
These are the same error if the implicit debugging plugin "splain" (https://github.com/tek/splain) is disabled:
My questions are:
What's the cause of this error? It clearly won't be caused by a missing dependent type (variable
aa
has a static path, butresult.arity
doesn't) So how is the macro unable to figure out the type foraa
?What should we do for any error that has such message? Should we debug or try to print the stacktrace?
The text was updated successfully, but these errors were encountered: