cairo icon indicating copy to clipboard operation
cairo copied to clipboard

bug: creating an array of structs with no fields

Open piotmag769 opened this issue 1 year ago • 3 comments

Bug Report

Cairo version:

2.4.3 Also added a test function to corelib and run ./scripts/cairo_test.sh - the issue still occurs

Current behaviour:

Cairo compilation fails when creating an array of structs with no fields

Related code:

With src/lib.cairo content:

#[derive(Drop)]
struct Y {}

fn func() {
    let y = Y{};
    array![y];
}

compilation with scarb build fails with

thread 'main' panicked at /Users/piotrmagiera/.cargo/git/checkouts/cairo-f086c7e6d4098a68/1c02dc5/crates/cairo-lang-sierra-generator/src/db.rs:194:6:
Got failure while specializing type.: TypeSpecialization { type_id: GenericTypeId("Array"), error: UnsupportedGenericArg }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

piotmag769 avatar Jan 05 '24 14:01 piotmag769

This should cause a compilation error instead of a panic.

Any particular reason you need it to actually compile specifically?

orizi avatar Jan 08 '24 20:01 orizi

@orizi I don't really need it, just accidentally encountered this panic lately

piotmag769 avatar Jan 09 '24 00:01 piotmag769

Good - was just making sure - diagnostic will be added.

orizi avatar Jan 09 '24 05:01 orizi