DSLX allows parameterized struct assignments with invalid width fields
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 130
Description
A struct with parameterized width-sized fields is not properly deduced when assigned from `TYPE { field-assignments...}`. Even if a particular type is requested (below: `Foo<5>`), the width-deduction happens on the rhs and then is never checked against the requested type.
```rust
pub struct Foo {
a: uN[WIDTH],
}
fn sizeof_foo(x: Foo) -> u32 {
WIDTH
}
#[test]
fn struct_assign_test() {
let x = Foo<5> { a:u17:1 }; // Want type Foo<5>, but with undetected typo ...
assert_eq(sizeof_foo(x), u32:17); // ... so actually got type Foo<17> instead
}
```
**Expected**: compile error pointing out the mismatch.
Contributor guide
Research direction
Start with the DSLX struct_assign_test example in the issue and reproduce its compilation behavior. The completed fix should reject Foo<5> { a:u17:1 } with a compile error identifying the mismatch between the requested parameterized type and the deduced field width.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100