[DSLX] Not able to assert on parametrics (as constexpr) in `const_assert!`
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
**Describe the bug**
Parametric values are flagging an issue in `const_assert!` as not being registered as constexpr -- I think this happens when we provide an incomplete set of parametrics -- the phantom parametric probably resolves to a `ParametricSymbol` (which we have intent to rip out) but the body of the function is still being evaluated for constexprs somehow. cc @richmckeever
**To Reproduce**
```
$ ~/opt/xlsynth/latest/dslx_interpreter_main reverse_chunks.x
reverse_chunks.x:19:3-19:36
0017:
0018: fn reverse_chunks(x: bits[FLAT]) -> bits[FLAT] {
0019: const_assert!(FLAT % N == u32:0); // Ensure FLAT is a multiple of N.
~~~~~~~~^-------------------------------^ TypeInferenceError: const_assert! expression is not constexpr
0020: const NUM_CHUNKS = FLAT / N;
```
Minimal reproducer:
```
fn f(x: bits[FLAT]) {
const_assert!(FLAT % N == u32:0);
}
#[test]
fn test_f() {
f(bits[42]:0)
}
```
```
$ ~/opt/xlsynth/latest/dslx_interpreter_main reverse_chunks.x
reverse_chunks.x:2:3-2:36
0001: fn f(x: bits[FLAT]) {
0002: const_assert!(FLAT % N == u32:0);
~~~~~~~~^-------------------------------^ TypeInferenceError: const_assert! expression is not constexpr
0003: }
0004:
```
**Expected behavior**
I'd expect this expression to be constexpr as the parametric values are compile-time constant, or to flag that not enough parametrics were provided to instantiate the function.
Contributor guide
Assessment
This issue has not been assessed yet.