Skip to content

Bug: tuple assignments can be miscompiled #40

Open
@alastairreid

Description

@alastairreid

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions