google / google/xls

[DSLX] Better error message when for-loop results are unused

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

Description

Coming from a non-dataflow-style loop it's easy to think we can just put a semicolon afterwards and that makes something happen:

```
for (i, accum) in range(u32:0, u32:4) {
...
}(init);
```

But really you want to capture the accum value or the loop effectively does nothing:

```
let accum = for (i, accum) in range(u32:0, u32:4) {
...
}(init);
```

We should make a nicer error message for this case where the user puts a semicolon and forgets to capture the result value with a "let". Right now it's a parse error expecting you to complete the function body (unexpected semi).

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.