-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Initialisation Exception #15832
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
but in Scala 3 it's
Scala 3 version can be simplified to the following snippet (foo1 does not need to be used in Foo.apply)
|
@WojciechMazur Thanks for looking into it so quickly. If it can't be changed then it would be nice if there was a compiler error rather than hitting this at runtime |
The cycle is induced by the superarg of |
@Arthurm1 I've never actually used this before, but:
Edit: I tried it with HEAD but no warning, although it fails the same way. |
@som-snytt That's handy thanks. I can see why it's not on by default - lots of false positives. |
The code is related to the safe initialization of global objects, for which we are still searching for a solution that balances safety, expressiveness, and performance. Related #9176. One design invariant for global objects we are considering is initialization-time irrelevance: the time when a global object is initialized should not change program semantics. /cc: @olhotak |
Thanks for looking into it @som-snytt . The behavior of the HEAD is expected, it's due to a recent improvement #15467. |
Compiler version
3.1.3 and 3.2.0-RC1 on Scastie
Minimized code
Output
Expectation
My initialisation ordering might be dubious but this works in Scala 2.
Works if I change
val foo1
tolazy val foo1
or if I put all the code intoobject A
The text was updated successfully, but these errors were encountered: