google / google/xls

Constexpr evaluation in impl methods doesn't always work

Open
#1,771 0 comments 0 reactions 0 assignees View on GitHub
dslx
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**Describe the bug**
`const_assert!()` doesn't seem to be able to constexpr-evaluate function parametrics.

**To Reproduce**
```
pub struct A {}
impl A {
fn B() -> bool {
const_assert!(C >= u32:4);
true
}
}
```

**Expected behavior**
It should typecheck and the assertion should pass or fail base on invocation.

Instead, I get `TypeInferenceError: const_assert! expression is not constexpr` regardless of the invocations of `A::B<...>()`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.