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

A let variable, initialized with a mutable variable behaves as an alias: it changes after change in the mutable variable: possible ssa regression #2054

Closed
alehander92 opened this issue Jul 26, 2023 · 0 comments · Fixed by #2057
Labels
bug Something isn't working

Comments

@alehander92
Copy link
Contributor

alehander92 commented Jul 26, 2023

Aim

We were trying to make our closure reforms PR pass the old higher_order_functions tests, and it seemed it didn't work with the alias of a mutable variable case: however it seems it is because this behavior changed

a minimal example is

use dep::std;

fn main() -> pub Field {
    let mut x = 2;
    let z = x;

    x = x + 1;
    assert(z == 2);
    x
}

Expected Behavior

Circuit witness successfully solved
Circuit output: Field(2)

Bug

instead we get

error: 
  ┌─ /home/al/noir/a/src/main.nr:8:12
  │
8 │     assert(z == 2);
  │            ------ Failed constraint

and an assert(z == 3) passes instead:

it seems, it worked as expected with the original ssa backend(tested before rebasing on a commit that drops it)

To Reproduce

write down a program like

use dep::std;

fn main() -> pub Field {
    let mut x = 2;
    let z = x;

    x = x + 1;
    assert(z == 2);
    x
}

and run it with

nargo execute

Installation Method

Compiled from source

Nargo Version

nargo 0.9.0 (git version hash: 0189e270bc6c15c26d3197400e76ef74ec285c6a, is dirty: true)

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@alehander92 alehander92 added the bug Something isn't working label Jul 26, 2023
@alehander92 alehander92 changed the title A let alias of a mutable variable also changes: possible ssa regression A let alias of a mutable variable changes after change in the mutable variable: possible ssa regression Jul 26, 2023
@alehander92 alehander92 changed the title A let alias of a mutable variable changes after change in the mutable variable: possible ssa regression A let variable, initialized with a mutable variable changes after change in the mutable variable: possible ssa regression Jul 26, 2023
@alehander92 alehander92 changed the title A let variable, initialized with a mutable variable changes after change in the mutable variable: possible ssa regression A let variable, initialized with a mutable variable behaves as an alias: it changes after change in the mutable variable: possible ssa regression Jul 26, 2023
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
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant