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

Assigning to a tuple member within if fails #1309

Closed
1 task
iAmMichaelConnor opened this issue May 6, 2023 · 3 comments · Fixed by #1318
Closed
1 task

Assigning to a tuple member within if fails #1309

iAmMichaelConnor opened this issue May 6, 2023 · 3 comments · Fixed by #1318
Assignees
Labels
bug Something isn't working

Comments

@iAmMichaelConnor
Copy link
Collaborator

iAmMichaelConnor commented May 6, 2023

Aim

let some_condition = false; // for example's sake
let mut my_tuple: (bool, bool) = (false, false);

if some_condition {
    my_tuple.0 = true;
else {
    my_tuple.0 = false;
}

This compilation fails with:

error: Expected an expression but found =
...
             my_tuple.0 = true;

If I replace the tuple (bool, bool) with an array [bool; 2] and access via my_tuple[0], it compiles.

Note: My tuple was actually made up of structs, rather than bools, but I distilled it down to this, for simplicity.

I'm using the aztec3-hacky branch, so it could be because of that...?

Expected behavior

Expected it to be able to assign to the element of the tuple.

Bug

See section above.

To reproduce

Installation method

None

Nargo version

nargo 0.4.0 (git version hash: 22c2234, is dirty: false)

@noir-lang/noir_wasm version

No response

@noir-lang/barretenberg version

No response

@noir-lang/aztec_backend version

No response

Additional context

No response

Submission Checklist

  • Once I hit submit, I will assign this issue to the Project Board with the appropriate tags.
@iAmMichaelConnor iAmMichaelConnor added the bug Something isn't working label May 6, 2023
@kevaundray
Copy link
Contributor

I'm using the aztec3-hacky branch, so it could be because of that...?

Possibly, it would be good to check that this is a bug on master too

@iAmMichaelConnor
Copy link
Collaborator Author

iAmMichaelConnor commented May 6, 2023

Just checked with v0.4.1:

fn main(my_tuple: (bool, bool), some_condition: bool) -> pub (bool, bool) {

    if some_condition {
        my_tuple.0 = true;
    } else {
        my_tuple.0 = false;
    }

    my_tuple
}
error: Expected an expression but found =
   ┌─ /mnt/user-data/mike/packages/yarn-project/noir-contracts/src/contracts/mike-play/src/main.nr:27:20
   │
27 │         my_tuple.0 = true;
   │                    -

error: Expected an expression but found =
   ┌─ /mnt/user-data/mike/packages/yarn-project/noir-contracts/src/contracts/mike-play/src/main.nr:29:20
   │
29 │         my_tuple.0 = false;
   │                    -

error: aborting due to 2 previous errors
Error: Failed to compile circuit

@jfecher
Copy link
Contributor

jfecher commented May 8, 2023

Worth noting this fails without the if as well - it seems we don't parse assigning to tuple fields at all.

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.

3 participants