Skip to content

Bug: tuple assignments can be miscompiled #40

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

Open
alastairreid opened this issue Feb 19, 2025 · 0 comments
Open

Bug: tuple assignments can be miscompiled #40

alastairreid opened this issue Feb 19, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@alastairreid
Copy link

I think that the following code can be mis-compiled

    (x, y) = (y, x);

This should swap x and y but, instead, we first assign "x = y;" and then "y = x;" which sets both x and y to the value that was in y.

More specifically, there is a potential problem for tuple assignments if the right hand side depends on the variables on the left hand side.

A workaround until this is fixed is to introduce some intermediate variables

let (t1, t2) = (y, x);
(x, y) = (t1, t2);
@alastairreid alastairreid added the bug Something isn't working label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant