-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Functions defined locally within a macro implementation cannot be used in a quote #16532
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
Labels
area:metaprogramming:quotes
Issues related to quotes and splices
area:reporting
Error reporting including formatting, implicit suggestions, etc
Milestone
Comments
|
Minimizedimport scala.quoted.*
def power0Impl(a: Expr[Int], b: Expr[Int])(using Quotes): Expr[Int] =
inline def recurseII(a:Int, n:Int): Int = ???
'{
val x2 = recurseII($a, $b)
// error: access to method recurseII from wrong staging level:
// - the definition is at level 0,
// - but the access is at level 1.
x2
} |
The error is correct. We could give a hint with an explanation. |
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Dec 22, 2022
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Dec 22, 2022
nicolasstucki
added a commit
to dotty-staging/dotty
that referenced
this issue
Dec 23, 2022
nicolasstucki
added a commit
that referenced
this issue
Dec 23, 2022
little-inferno
pushed a commit
to little-inferno/dotty
that referenced
this issue
Jan 25, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area:metaprogramming:quotes
Issues related to quotes and splices
area:reporting
Error reporting including formatting, implicit suggestions, etc
Compiler version
Version 3.2.1
Minimized code
I have a set of "standard" functions defined locally within a macro implementation. I cannot seem to be able to place these in a quote. The global version of the methods work correctly. May not be a bug, but is not intuitive. Here is the code (also in scastie):
Output
Expectation
I expect the functions defined within the macro implementation to work as any other.
The text was updated successfully, but these errors were encountered: