-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Miscompilation: When a try
expression mutating a var
is lifted, incorrect code is generated
#7356
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
try
expression mutating a var
is lifted, incorrect code is generatedtry
expression mutating a var
is lifted, incorrect code is generated
try
expression mutating a var
is lifted, incorrect code is generatedtry
expression mutates a var
is lifted, incorrect code is generated
try
expression mutates a var
is lifted, incorrect code is generatedtry
expression mutating a var
is lifted, incorrect code is generated
I agree that
Since LazyVals and CapturedVars are in the same group we are out of choices. I looked at t2333.scala. The problem is that LazyVals generates this code:
and then LiftTry fails to lift out the
which seems to indicate that no lifting is necessary. But once LazyVals did its job lifting is in fact necessary. Possible remedies:
Number (2) is the better fix, since it avoids unnecessary lifting. |
Note that the algorithm for redesigned lazyvals #6979 would not have this problem. The initializing code is not passed as an argument there. |
This should print
bar
but it printsfoo
instead, because the generated code looks like this:This is of course non-sensical (we're mutating a method parameter!) and is detected by the compiler under
-Ycheck:all
. EitherLiftTry
needs to be taught to handle vars, or it needs to be moved beforeCapturedVars
.The text was updated successfully, but these errors were encountered: