Const generic arithmetic in array types not evaluated during unification
- Dominant language
- Rust
- Stars
- 1.7k
- Forks
- 218
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 9
Description
Array types using const arithmetic like `[T; N + 1]` parse and check fine in the struct definition, but fail when instantiated because `(1 + 1)` isn't reduced to `2` for type matching.
```fe
struct G1 {
pub x: u256,
pub y: u256,
}
struct Vk {
pub ic: [G1; N + 1],
}
fn make_vk() -> Vk<1> {
Vk {
ic: [G1 { x: 3, y: 4 }, G1 { x: 5, y: 6 }],
}
}
```
```
error: expected `[G1; (1 + 1)]`, but `[G1; 2]` is given
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by compiling the reproducer in the issue and inspect the type-matching path used when constructing Vk<1>. Compare the array length expressions N + 1 and 2 during unification; done means the example type-checks with the arithmetic expression reduced to the concrete length.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100