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

Panic when using nested dynamic arrays #5782

Closed
jfecher opened this issue Aug 21, 2024 · 1 comment · Fixed by #5810
Closed

Panic when using nested dynamic arrays #5782

jfecher opened this issue Aug 21, 2024 · 1 comment · Fixed by #5810
Labels
bug Something isn't working

Comments

@jfecher
Copy link
Contributor

jfecher commented Aug 21, 2024

Aim

fn main(mut array: [Field; 2], i: u32) {
    array[i] = 2;

    let array2 = [array, array];
    println(array2[i][i]);
}

Expected Behavior

The value of array2[i][i] to be printed

Bug

The application panicked (crashed).
Message:  internal error: entered unreachable code: Dynamic array should already be initialized
Location: compiler/noirc_evaluator/src/ssa/acir_gen/acir_ir/acir_variable.rs:1966

This is a bug. We may have already fixed this in newer versions of Nargo so try searching for similar issues at 
https://github.com/noir-lang/noir/issues/.
If there isn't an open issue for this bug, consider opening one at https://github.com/noir-lang/noir/issues/new?labels=bug&template=bug_report.yml

To Reproduce

Workaround

None

Workaround Description

No response

Additional Context

No response

Project Impact

None

Blocker Context

No response

Nargo Version

No response

NoirJS Version

No response

Proving Backend Tooling & Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

@jfecher jfecher added the bug Something isn't working label Aug 21, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Aug 21, 2024
@jfecher
Copy link
Contributor Author

jfecher commented Aug 21, 2024

I was experimenting with an optimization to optimize array merges across if conditions using [array1, array2][cond as u32] but this bug prevents that.

github-merge-queue bot pushed a commit that referenced this issue Aug 23, 2024
# Description

## Problem\*

Resolves #5782 

## Summary\*

We are using our recursive `initialize_array_inner` function to also
check whether the outer AcirValue we are trying to initialize is a
dynamic array. We should be able to initialize a new AcirValue::Array
with internal AcirValue::DynamicArray types.

## Additional Context



## Documentation\*

Check one:
- [X] No documentation needed.
- [ ] Documentation included in this PR.
- [ ] **[For Experimental Features]** Documentation to be submitted in a
separate PR.

# PR Checklist\*

- [X] I have tested the changes locally.
- [X] I have formatted the changes with [Prettier](https://prettier.io/)
and/or `cargo fmt` on default settings.
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Aug 23, 2024
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
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant