xls icon indicating copy to clipboard operation
xls copied to clipboard

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

Open cdleary opened this issue 4 years ago • 0 comments

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).

cdleary avatar Dec 01 '20 22:12 cdleary