-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Stale symbol for top-level alias type in suspended compilation unit #19351
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
|
Moving This is an issue with suspension of the compilation unit. |
MinimizationCompiling the following two files at the same time type Alias = Int
inline def myMacro(): Alias = ${myMacroExpr}
def test = myMacro() import scala.quoted.*
def myMacroExpr(using Quotes): Expr[Alias] = '{???} |
Same issue for other definitions that move into the package object. val x: Int = 1
inline def myMacro(): x.type = ${myMacroExpr}
def test = myMacro() import scala.quoted.*
def myMacroExpr(using Quotes): Expr[x.type] = '{???} |
I can confirm that just moving the alias to a different scope even in the same file fixes the problem. object BoolType:
type Bool = [R] => (R, R) => R
val True: Bool = [R] => (t: R, _: R) => t
val False: Bool = [R] => (_: R, f: R) => f
import BoolType.*
inline def not(b: Bool): Bool = ${notMacro('b)}
inline def show(b: Bool): String = ${showMacro('b)} I would be ok if the compiler produced an error that explained what was wrong instead of crashing. Definition 'not' used macro 'notMacro' which attempted to access 'Bool' in a suspended compilation unit. But I guess this might be difficult to diagnose when the error involves a lot of transitive references? |
This is probably crashing due to a stale symbol, maybe similar to #18077. This should be fixed. |
In all the examples there is an illegal cyclic dependency between the two units. In the minimization it is the |
…ies (#19549) If a suspended macro refers back to a symbol in a previously compiled package object, report this as an error instead of crashing with a StaleSymbol exception. There's unfortunately not a lot of info available at the point where the error is raised, so the error message is a bit vague. But it's better than crashing. Fixes #19351
Compiler version
3.3.1 (same with 3.4.0-RC1)
Minimized code
If you swap the not/show wilth the fold versions then it doesn't crash.
I guess its some issue with inferring the [R] ?
The text was updated successfully, but these errors were encountered: