[DSLX] can't use parametric constexprs in struct definition
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
**Describe the bug**
I'm unable to do something with parametrics; I think it should be legal. As best as I can tell, the narrowest definition of the bug is: I can't use constexprs in a struct's parametric definitions.
**To Reproduce**
```
pub struct FixedPoint u32:0} > {
data: xN[SIGNED_BOOL][NUM_BITS],
}
#[test]
fn test_instantiate_FixedPoint() {
let a = FixedPoint { data: u5:1};
assert_eq(a.data, u5:1);
}
```
Build and _test_ the above. The error shows up during the test.
```
Error: INVALID_ARGUMENT: Cannot convert expression to parametric: SIGNED > u32:0================================================================================
```
**Expected behavior**
It should work, the test should pass.
**Additional context**
If you're wondering why I made SIGNED a u32 instead of bool, see [this bug.](https://github.com/google/xls/issues/1841)
I find it strange that this error appears at test runtime instead of typechecking.
Contributor guide
Assessment
This issue has not been assessed yet.