-
Notifications
You must be signed in to change notification settings - Fork 1.1k
QuoteContext show can show code that does not compile #8585
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
That looks like a rather tall order. Macro-generated code might not compile when printed as source in a myriad different ways. I agree it would be useful to have this, but it looks like a sizeable project on its own to get there. |
@odersky thanks for the insight. Is there a way to see more directly what code was generated/run by the staging process? |
The staged code uses internal symbols instead of printable names. That's what makes it hard to print correctly in the first place. |
#7388 would give a way to print this code without repeating names. |
Fix #8585: Refresh names to avoid name clashes
The following code is based of the dotty-staging.g8 project.
It has been slightly trimmed and modified such that
powerCode
recursively calls itself twice.This results in generating two lines starting
val y: scala.Double =
.Output
Running this yields the following output:
Attempting to compile that source code yields an error:
Expectation
code.show
should produce a source code representation that compiles.We can, however, see that the staging works and we get our answer
3^8 = 6561
The text was updated successfully, but these errors were encountered: