-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Match Error in dotty when trying to do Apply with block as first argument from macro API #18113
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
Comments
The block is valid only if the result is mapped to a function value. Right now it is a method, which cannot be returned from a block. We could maybe move the block outwards as a convenience feature. But I don't see how not doing that is a bug. |
Hmm, I think that the obvious interpretation is that the result of a block is the last expression of that block, so the block is a functional value. I.e. Apply with block is a native sequence of calls to recreate the following expression:
(which is possible to write in code). |
It's not possible in typed code, though. The typed code equivalent would be { ref.x = 1; x => ref.plus(x) }.apply(2) |
Or, written out { ref.x = 1; { def $anonfun(x: Int) = ref.plus(x); closure($anonfun) }}.apply(2) |
We could detect ill-formed |
Eta-expanded application also can't be passed to apply.
We have the same error. What actually works in ```Apply(Select(etaExpaned,"apply"), params)````
This is not an issue itself, but it should be documented. |
Also improve the stack trace shown to the user when a macro assertion fails. Fixes scala#18113
Compiler version
3.3.0, 3.3.2-RC1-bin-SNAPSHOT as today
Minimized code
file X.scala:
fille Main.scala:
Output
Expectation
It should be compiled.
The text was updated successfully, but these errors were encountered: