You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importscala.quoted.*deftestExprImpl(body: Expr[Any])(usingQuotes):Expr[String] =
body matchcase'{ (a:Int) => (${'{1+ ($b(a) :Int)}} :Int) } =>'{ $b(1).toString }
case _ =>Expr("not matched"
)
Output
--Warning:Macro.scala:6:24---------------------------------------------------6|case'{ (a:Int) => (${'{1+ ($b(a) :Int)}} :Int) } =>| ^^^^^^^^^^^^^^^^^^^^^^^
|Canceled quote directly inside a splice. ${ '{ XYZ } } is equivalent to XYZ.
--Error:Macro.scala:6:36-----------------------------------------------------6|case'{ (a:Int) => (${'{1+ ($b(a) :Int)}} :Int) } =>| ^
| access to parameter a from wrong staging level:
|- the definition is at level 0,
|- but the access is at level 1.
1 warning found
1 error found
Expectation
If the working message is correct, it should compile as well as case '{ (a:Int) => 1 + ($b(a) : Int) } =>.
or, considering the behavior of (hoas) splice pattern, it is also reasonable to to conclude that $'{...} is not equivalent to ... as a pattern. In this case, we want to change the warning message.
The current error message informal about staging level, which seems not right. Instead, it should show an error message like "a is undefined in this scope".
The text was updated successfully, but these errors were encountered:
Compiler version
3.3.0
Minimized code
Output
Expectation
case '{ (a:Int) => 1 + ($b(a) : Int) } =>
.$'{...}
is not equivalent to...
as a pattern. In this case, we want to change the warning message.a
is undefined in this scope".The text was updated successfully, but these errors were encountered: