noir-lang / noir

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

`Option<[u8]>::none()` panics at SSA #5429

Closed michaeljklein closed 1 month ago

michaeljklein commented 2 months ago

Aim

Ran nargo compile on:

fn main() {
    let _: Option<[u8]> = Option::none();
}

Expected Behavior

The program to compile without errors

Bug

❯ nargo compile
The application panicked (crashed).
Message:  internal error: entered unreachable code: ICE: unexpected array literal type, got [u8]
Location: compiler/noirc_evaluator/src/ssa/ssa_gen/mod.rs:203

To Reproduce

1. 2. 3. 4.

Project Impact

None

Impact Context

No response

Workaround

None

Workaround Description

No response

Additional Context

No response

Installation Method

None

Nargo Version

nargo version = 0.31.0 noirc version = 0.31.0+7b77bbfc19c51829814149e623257a3424d8e8c2 (git version hash: 7b77bbfc19c51829814149e623257a3424d8e8c2, is dirty: true)

NoirJS Version

No response

Would you like to submit a PR for this Issue?

None

Support Needs

No response

asterite commented 1 month ago

This also reproduces the same issue:

fn main() {
    let _: [u8] = std::unsafe::zeroed();
}

@noir-lang/core Is there a way for zeroed to work on slices? Maybe it's just a tuple (0, 0)?

jfecher commented 1 month ago

@asterite should just be an empty slice &[]. IIRC we already do this as well.