Skip to content

Compiler panics when using type aliases and arrays defined using const generics #7604

@ironcev

Description

@ironcev

#7601 introduces a should_pass/language/const_generics_array_in_reassignments tests with the following code snippet:

trait ConstructSelf<D> {
    fn construct_self(default: D) -> Self;
}

impl<T, const N: u64> ConstructSelf<T> for [T; N]
where
    T: AbiEncode + PartialEq,
{
    fn construct_self(default: T) -> Self {
        let mut array = [default; N];
        let mut i = 0;
        while i < N {
            array[i] = default;
            assert_eq(array[i], default);
            i += 1;
        }
        array
    }
}

type ArrayU842 = [u8;42];

When calling:

let array = ArrayU842::construct_self(42u8);

the compiler panics with:

thread 'main' (2868621) panicked at sway-core/src/ir_generation/const_eval.rs:554:13:
assertion failed: decl.value.is_some()

Related to #7616.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompilerGeneral compiler. Should eventually become more specific as the issue is triagedcompiler: frontendEverything to do with type checking, control flow analysis, and everything between parsing and IRgencompiler: irIRgen and sway-ir including optimization passes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions