noir-lang / noir

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

Missing call result after inlining #1698

Closed joss-aztec closed 1 year ago

joss-aztec commented 1 year ago

Aim

Test named poseidonsponge_x5_254 should compile

Expected Behavior

^

Bug

The application panicked (crashed).
Message:  internal error: entered unreachable code: ICE: Value Id(845) should have been in cache Instruction { instruction: Id(475), position: 0, typ: Numeric(NativeField) }
Location: crates/noirc_evaluator/src/ssa_refactor/acir_gen/mod.rs:345

Appears that v845 should be the result of calling sponge, but it's definition doesn't exist. Furthermore the result of the inlining pass is surprisingly short. (The initial SSA is over 300 lines.)

fn main f9 {
  b0(v0: [Field; 7]):
    v375 = cast Field 5 as u8
    v377 = mul v375, u8 68
    v378 = truncate v377 to 8 bits, max_bit_size: 16
    v380 = cast Field 340 as u8
    v381 = eq v378, v380
    constrain v381
    v390 = allocate
    store [Field 0, Field 0, Field 0, Field 0, Field 0] at v390
    v391 = allocate
    store Field 0 at v391
    v847 = eq v845, Field 3637726918731233354960448572465528704217843406233123660822069175839457651784
    constrain v847
    return 
}

To Reproduce

1. 2. 3. 4.

Installation Method

None

Nargo Version

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

jfecher commented 1 year ago

After some investigation the reason for this error is the same as in #1688. The ValueIds in arrays are not being updated.

kevaundray commented 1 year ago

Can we close this as fixed?

joss-aztec commented 1 year ago

Yes, poseidonsponge_x5_254 is now failing because of GH-1756 instead.