-
Notifications
You must be signed in to change notification settings - Fork 1.1k
incorrect ScopeException with -Xcheck-macros when few functions is generate slices inside common Quote #14137
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
(after thinking -- maybe exists way to add something like @nowarn annotation ) |
This reverts commit d9db9ee.
Maybe related to #13926 |
Yes, I think this is duplicate |
The error showed a quote that was created with the wrong package x
import scala.quoted._
object Macro:
inline def genOp(inline f:Int): Int = ${
genOpImpl('f)
}
def genOpImpl(f: Expr[Int])(using Quotes): Expr[Int] = {
def firstOp(): Expr[Int] =
'{
var x=1
${secondOp('x,f)}
}
- def secondOp(x:Expr[Int], y:Expr[Int]): Expr[Int] =
+ def secondOp(x:Expr[Int], y:Expr[Int])(using Quotes): Expr[Int] =
'{ $x + $y }
firstOp()
} The compiler can still detect and fix the mistake, but it will cost it some more circles to fix it. If this pattern is nested repeatedly it can have an exponential cost. |
What we do need is a better way to hint at how to fix these errors in the error itself. |
This reverts commit d9db9ee.
Compiler version
3.1.1-RC1
Minimized code
-Xcheck-macros should be in compiler flags.
file M.scala
file X.scala:
Output
Expectation
should be compiled
The text was updated successfully, but these errors were encountered: