google / google/xls

ParseErrors for unroll_for! with shorthand .. range using imported constant

Open
#1,964 0 comments 0 reactions 0 assignees 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**

```
proc Foo {
config() { }

init { () }

next(state: ()) {
unroll_for! (i, _): (u32, ()) in u32:0..bar::N {
let tok_ = join();
}(());
}
}
```

where in `bar` module:

```
pub const N = u32:32;
```

causes the error:

```
Expected 'identifier', got 'keyword:let': Expected struct instance's member name
=== Source Location Trace: ===
xls/dslx/frontend/bindings.h:59
xls/dslx/frontend/parser.cc:1079
...
```

Removing the statement inside interestingly causes a different error:

```
Expected '{', got ';'
=== Source Location Trace: ===
xls/dslx/frontend/bindings.h:59
xls/dslx/frontend/token_parser.cc:102
xls/dslx/frontend/parser.cc:3499
```

**To Reproduce**

Run the above proc through the DSLX formatter or compile it.

**Expected behavior**
This should work just as `range(u32:0, bar::N)` does.

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.