Skip to content

Mismatch in compiler behavior when passing input program that uses BoundedInts #1479

Description

@gabrielbosio

The following program:

impl H1 of DivRemHelper<BoundedInt<0, 10>, BoundedInt<1, 10>> {
    type DivT = BoundedInt<0, 9>;
    type RemT = BoundedInt<0, 9>;
}

#[inline(never)]
fn baz(a: BoundedInt<0, 10>, b: BoundedInt<1, 10>) -> felt252 {
    let (q, _r) = div_rem(a, bounded_int_wrap_non_zero(b));
    match q {
        0 => 0x100,
        1 => 0x10000,
        2 => 0x1000000,
        3 => 0x100000000,
        4 => 0x10000000000,
        5 => 0x1000000000000,
        6 => 0x100000000000000,
        7 => 0x10000000000000000,
        8 => 0x1000000000000000000,
        9 => 0x100000000000000000000,
        _ => core::panic_with_felt252('unreachable - no code generated'),
    }
}

Causes both Sierra compiler of Cairo 2.13.0 and 2.14.0 to fail with the following error:

Error: Compilation failed.

Caused by:
    #3: One of the arguments does not match the expected type of the libfunc or return statement.

But Native does compile this program and then fails when executing it with:

Invalid enum tag.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions