You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note how the assignment of j is moved outside the if-expression despite the move changing the evaluation of the condition of the if-expression. The code without the surrounding { and } is compiled correctly.
Thanks for reporting.
This seems to be a long standing issue, that can be reproduced already on old versions of the compiler.
Seems to be triggered by not exporting variable j, by either putting the code into { ... } block or shadowing the variable.
This appears to be due to an optimisation for records with only one field, such as contents.
The optimisation should only affect the generated code, but in this case prematurely turning x.contents into x confuses the checker for side effects, which thinks there are none.
Activity
cristianoc commentedon Nov 24, 2024
Thanks for reporting.
This seems to be a long standing issue, that can be reproduced already on old versions of the compiler.
Seems to be triggered by not exporting variable
j, by either putting the code into{ ... }block or shadowing the variable.cristianoc commentedon Nov 24, 2024
This appears to be due to an optimisation for records with only one field, such as
contents.The optimisation should only affect the generated code, but in this case prematurely turning
x.contentsintoxconfuses the checker for side effects, which thinks there are none.Fix bug where a ref assignment is moved ouside a conditional
Fix bug where a ref assignment is moved ouside a conditional
Fix bug where a ref assignment is moved ouside a conditional
Fix bug where a ref assignment is moved ouside a conditional