google / google/xls

[DSLX] Internal error constexpr value not found for local type alias

Open
#1,870 3 comments 0 reactions 1 assignee Claimed by @cdleary View on GitHub
bug dslx
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

**Describe the bug**

```dslx
fn get_max() -> uN[N] {
// Note: there is a temporary grammar limitation that prevents us from
// directly doing `uN[N]::MAX` so we must use a type alias.
type OutputType = uN[N];
OutputType::MAX
}

#[test]
fn show_numeric_limits() {
assert_eq(get_max(), u4:0xf);
assert_eq(get_max(), u5:0x1f);
}
```
gives:

```
Error: [ RUN UNITTEST ] show_numeric_limits
E0119 13:28:40.597487 1905801 run_routines.cc:110] Internal error: NOT_FOUND: No constexpr value found for node `N` (NameRef) @ /tmp/tmpio5sr9b5.dslx:4:26-4:27
[ FAILED ] show_numeric_limits: internal error: NOT_FOUND: No constexpr value found for node `N` (NameRef) @ /tmp/tmpio5sr9b5.dslx:4:26-4:27
[===============] 1 test(s) ran; 1 failed; 0 skipped.
```

**To Reproduce**
Run the DSLX interpreter on the above snippet in a file.

**Expected behavior**
The type alias should work with the N binding in local scope.

**Environment (this can be helpful for troubleshooting):**
- OS: Ubuntu
- Versions 24.04.1 LTS

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.