-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Strange Error while emitting error when adding a new member to Surface
#20072
Comments
Another repro of the same issue, might be a better starting point for possible minification, is branch The code compiles fine in the commit before the last one, it crashes as soon as you comment The critical code fragment is:
It seems you need to provide all arguments to Rant: I have worked with Scala 2 macros before, and while design of Scala 3 macros looks elegant and powerful, the implementation is ridden with so many issues that doing anything with them is very frustrating. Esp. the error messages are most often not helpful, crashes happen somewhere inside of the compiler, callstacks do not include the inlining chains. Following quote sounds more like a dream:
|
I am trying to reduce the repro. Creating a small repro from scratch did not work, therefore I remove parts of code from the original repro and I am gradually reducing its size. |
This is how the generated expression looks like with the explicit argument present. The value is obtained by logging new org.opengrabeso.airframe.surface.GenericSurface(classOf[X], typeArgs = scala.Seq.empty[scala.Nothing], docString = scala.None) and this is how it looks without it, using the default value:
In the second case the compiler seems to insert some helper variables which then fail for some obscure reason. |
The repro is reduced to a single file, 160 lines, and a test file. I doubt I can reduce it much more, in particular I cannot remove |
I can create the error even without using default values. This gives the error: val surface = '{
val none = None
new org.opengrabeso.airframe.surface.Surface(none)
} This does not: val surface = '{
val none = None
new org.opengrabeso.airframe.surface.Surface(None)
} Also no error happens when I replace the
When I provide the same expression explicitly, no error happens. When I use
I am not sure what this all means. |
The issue can be fixed by using ValDef(sym, Some(surfaceOf(tpe, useVarRef = false).asTerm.changeOwner(sym))) |
Fixes issue investigated as scala/scala3#20072 Unfortunately there are still other issues preventing compiling with `-Xcheck-macros` (https://stackoverflow.com/questions/78193025/how-to-extract-type-parameter-from-typelambda-correctly), but this fix is an important step in that direction.
Caused by a bad owner on the macro side, not a compiler issue. |
Compiler version
3.3.3
3.4.1
3.5.0-RC1-bin-20240331-cc55381-NIGHTLY
Minimized code
test
from sbtOutput
See https://github.com/OpenGrabeso/light-surface/actions/runs/8525399157/job/23352226318
Expectation
No error. The code compiles fine when you comment out
override val docString: Option[String] = None,
and there is no reason why it should not compile with it.This is driving me crazy. I have made many changes to this class before and I never had any issues with it, it is based on https://wvlet.org/airframe/docs/airframe-surface
The text was updated successfully, but these errors were encountered: