Compiler panics when using type aliases and arrays defined using const generics
- Dominant language
- Rust
- Stars
- 61.4k
- Forks
- 5.4k
- Avg merge
- 3h 33m
- Merged PRs (30d)
- 4
Description
#7601 introduces a `should_pass/language/const_generics_array_in_reassignments` tests with the following code snippet:
```sway
trait ConstructSelf {
fn construct_self(default: D) -> Self;
}
impl ConstructSelf 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:
```sway
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the should_pass/language/const_generics_array_in_reassignments test and reproduce the type-alias call using the provided snippet. Then inspect sway-core/src/ir_generation/const_eval.rs at the reported assertion, and verify that the test compiles and runs without a compiler panic after the issue is addressed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 67/100