Type checking reports incorrect constexpr error in const_assert! when parametric is not specified
- Dominant language
- C++
- Stars
- 1.9k
- Forks
- 283
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 135
Description
**Describe the bug**
In certain cases(?), `const_assert!` fails typechecking due to a reported "expression is not constexpr". However, it is in fact constexpr, just the parametric used in the expression was not specified by the invocation.
**To Reproduce**
```
const FOO_COUNT = u32:8;
fn foo() -> u32 {
const_assert!(IDX < FOO_COUNT);
u32:0
}
#[test]
fn foo_test() {
let x = foo();
assert_eq(x, u32:0);
}
```
```
Error: INVALID_ARGUMENT: TypeInferenceError: ... const_assert! expression is not constexpr
=== Source Location Trace: ===
xls/dslx/errors.cc:44
xls/dslx/type_system/deduce.cc:2205
xls/dslx/type_system/deduce.cc:2219
xls/dslx/type_system/deduce_ctx.cc:146
xls/dslx/type_system/deduce.cc:792
xls/dslx/type_system/deduce.cc:2205
xls/dslx/type_system/deduce.cc:2219
xls/dslx/type_system/deduce_ctx.cc:146
xls/dslx/type_system/deduce.cc:862
xls/dslx/type_system/deduce.cc:2205
xls/dslx/type_system/deduce.cc:2219
xls/dslx/type_system/deduce_ctx.cc:146
xls/dslx/type_system/typecheck_invocation.cc:504
xls/dslx/type_system/deduce_invocation.cc:440
xls/dslx/type_system/deduce.cc:2205
xls/dslx/type_system/deduce.cc:2219
xls/dslx/type_system/deduce_ctx.cc:146
xls/dslx/type_system/deduce_ctx.cc:202
xls/dslx/type_system/deduce.cc:352
xls/dslx/type_system/deduce.cc:2205
xls/dslx/type_system/deduce.cc:2219
xls/dslx/type_system/deduce_ctx.cc:146
xls/dslx/type_system/deduce.cc:792
xls/dslx/type_system/deduce.cc:2205
xls/dslx/type_system/deduce.cc:2219
xls/dslx/type_system/deduce_ctx.cc:146
xls/dslx/type_system/deduce.cc:862
xls/dslx/type_system/deduce.cc:2205
xls/dslx/type_system/deduce.cc:2219
xls/dslx/type_system/deduce_ctx.cc:146
xls/dslx/type_system/deduce_ctx.cc:202
xls/dslx/type_system/typecheck_function.cc:200
xls/dslx/type_system/typecheck_module.cc:391
xls/dslx/type_system/typecheck_module.cc:391
xls/dslx/parse_and_typecheck.cc:114
```
**Expected behavior**
It should report the invocation in the test does not specify a required parametric.
Contributor guide
Assessment
This issue has not been assessed yet.