Skip to content

Compiler ICE when accessing self[i] where self is defined using const generics [T;N] #7602

@ironcev

Description

@ironcev

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

impl<T, const N: u64> DefaultSelf<T> for [T; N]
where
    T: AbiEncode + PartialEq,
{
    fn default_self(ref mut self, default: T) {
        let mut i = 0;
        while i < N {
            self[i] = default;             // <<<<---- This works as expected.
            assert_eq(self[i], default);   // <<<<---- This causes ICE.
            i += 1;
        }
    }
}

The self[i] access in the assert_eq results in:

assert_eq(self[i], default);
          ^^^^ Internal compiler error: Unsupported array value for index expression.

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 IRgen

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions