-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Lazy val with constant type loses side effects. #2266
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
DarkDimius
added a commit
that referenced
this issue
Apr 19, 2017
Fix #2266: Do not replace constant type lazy vals with constant.
odersky
added a commit
that referenced
this issue
Apr 29, 2017
…vals Revert "Fix #2266: Do not replace constant type lazy vals with constant."
Should this issue be opened? Looks like it was closed automatically by a commit that reverted the fix. |
scalac prints the "X", so this is a change in behavior that should be fixed. |
👍 Also, Scala 3 is also |
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 5, 2022
We previously converted an expression with constant type to a literal if the expression was idempotent. This can hide side effects in the case where the expression is a selection from an object or lazy val. Demanding purity instead prodcues tons of errors involving inline vals on objects. We now demand idempotency if the expression refers to an inline val (or an operation over an inline val), and purity elsewhere. Fixes scala#2266
odersky
added a commit
to dotty-staging/dotty
that referenced
this issue
Apr 5, 2022
We previously converted an expression with constant type to a literal if the expression was idempotent. This can hide side effects in the case where the expression is a selection from an object or lazy val. Demanding purity instead prodcues tons of errors involving inline vals on objects. We now demand idempotency if the expression refers to an inline val (or an operation over an inline val), and purity elsewhere. Fixes scala#2266
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does not print
X
.The text was updated successfully, but these errors were encountered: