Skip to content
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

destructuring problem #19747

Closed
lixiaoqiang opened this issue Apr 23, 2024 · 5 comments
Closed

destructuring problem #19747

lixiaoqiang opened this issue Apr 23, 2024 · 5 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@lixiaoqiang
Copy link

Zig Version

0.12.0

Steps to Reproduce and Observed Behavior

    var x: i32 = 1;
    var y: i32 = 2;
    y, x = .{ x, y };
    std.debug.print("x = {d}, y = {d}\n", .{ x, y });

expect output : "x = 2, y = 1"
but get: "x = 1,y = 1"

Expected Behavior

expect output : "x = 2, y = 1"
but get: "x = 1,y = 1"

@lixiaoqiang lixiaoqiang added the bug Observed behavior contradicts documented or intended behavior label Apr 23, 2024
@lixiaoqiang
Copy link
Author

May be by design?

@Rexicon226
Copy link
Contributor

Rexicon226 commented Apr 23, 2024

Afaik this is a bug. Probably caused by not copying backwards in these edge cases. Quicky bit of research shows that in Zir we are in fact not creating a temporary to hold either x or y. Copy order is irrelevant.

cc @mlugg

@nektro
Copy link
Contributor

nektro commented Apr 23, 2024

likely duplicate #12064

@Rexicon226
Copy link
Contributor

It is.

@Vexu Vexu closed this as not planned Won't fix, can't repro, duplicate, stale Apr 23, 2024
@mlugg
Copy link
Member

mlugg commented Apr 23, 2024

Yep, not a bug, just how RLS works today, and the linked issue tracks it as a design flaw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

5 participants