[DSLX] In struct parametrics `as` is not constexpr-compatible
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
**Describe the bug**
Try to build this:
```
pub struct foo {
data: xN[IS_SIGNED as u1][NUM_BITS],
}
#[test]
fn test_instantiate_foo() {
let _ = foo { data: u1:0};
}
```
observe error:
```
Could not evaluate dimension expression `IS_SIGNED as u1` to a constant value.
```
**To Reproduce**
Use code above, try to compile.
**Expected behavior**
I expect that I can cast a `u32` to a `u1` to define a type. That is, I expect that casting is constexpr-compatible.
**More comments**
I tried another way of accomplishing the same thing:
```
pub struct foo u32:0} > {
data: xN[sign][NUM_BITS],
}
#[test]
fn test_instantiate_foo() {
let _ = foo { data: u1:0};
}
```
and when I try to build and test:
```
Error: INVALID_ARGUMENT: Cannot convert expression to parametric: IS_SIGNED > u32:0
```
let's try again, but same error (i.e., Cannot convert expression to parametric):
```
pub struct foo u32:0 {true}else{false}} > {
data: xN[sign][NUM_BITS],
}
```
Contributor guide
Assessment
This issue has not been assessed yet.