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

Expected array value - Error with arrays while in a for loop #2538

Closed
keccakk opened this issue Sep 3, 2023 · 1 comment · Fixed by #2446
Closed

Expected array value - Error with arrays while in a for loop #2538

keccakk opened this issue Sep 3, 2023 · 1 comment · Fixed by #2446
Labels
bug Something isn't working

Comments

@keccakk
Copy link

keccakk commented Sep 3, 2023

Expected Behavior

To be able to change a value of an array while inside a for loop.

Bug

[test] Running 1 test functions
[test] Testing test_main... The application panicked (crashed).
Message:  Expected array value
Location: crates/noirc_evaluator/src/ssa/opt/flatten_cfg.rs:427

To Reproduce

fn main() {
  let mut a: [Field] = [1, 2, 3];
  let mut b: [Field] = [4, 5, 6];

  for i in 0..2 {
    if a[i] == 2 {
      // Bug occurs in following line
      b[i + 1] = b[i] * b[i + 1];
    }
  }
}

#[test]
fn test_main() {
  main();
}

Installation Method

Binary

Nargo Version

nargo 0.10.5 (git version hash: f1d09ca

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@keccakk keccakk added the bug Something isn't working label Sep 3, 2023
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Sep 3, 2023
@vezenovm
Copy link
Contributor

vezenovm commented Sep 5, 2023

The work around for now is to use [Field; 3] rather than slices in your program. But this is fixed here (#2446) which we are working on getting merged into master.

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Sep 7, 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.

2 participants