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

Mutable variables alias instead of copy #201

Open
jfecher opened this issue Aug 11, 2024 · 0 comments
Open

Mutable variables alias instead of copy #201

jfecher opened this issue Aug 11, 2024 · 0 comments

Comments

@jfecher
Copy link
Owner

jfecher commented Aug 11, 2024

x = mut 4
y = x
print y
x := 5
print y

Expected to print 4 twice, but it instead prints 4 then 5.
This can be seen in the hir (--emit-hir):

x_v0 = (#StackAlloc 4_i32);
y_v1 = x_v0;
(print_v2 y_v1);
x_v0 := 5_i32;
(print_v2 y_v1)

x is a stack-allocated pointer, but y does not dereference it as it should. This is a code-gen issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant