noir-lang / noir

Noir is a domain specific language for zero knowledge proofs
https://noir-lang.org
Apache License 2.0
893 stars 199 forks source link

Panic when using nested dynamic arrays #5782

Closed jfecher closed 2 months ago

jfecher commented 2 months ago

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

1. 2. 3. 4.

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 commented 2 months ago

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