Skip to content

Compiler ICE caused by invalid type unification of arrays #7603

@ironcev

Description

@ironcev

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

    array.default_self(42);       //  <<<<---- `array` is of type `[u8;3]`.
    assert_eq([42u8; 3], array);  //  <<<<---- This works as expected.
    assert_eq([42; 3], array);    //  <<<<---- This causes ICE.

where default_self is defined as:

impl<T, const N: u64> DefaultSelf<T> for [T; N]
where
    T: AbiEncode + PartialEq,
{
    fn default_self(ref mut self, default: T) {
        ...
    }
}

Calling assert_eq without explicitly specifying the type causes:

error: Internal compiler error: Verification failed: init_aggr instruction has an initializer with a type mismatch for array element at index 0. Expected element type: u8, found initializer type: u64.

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