-
Notifications
You must be signed in to change notification settings - Fork 226
[enhancement] dslx should support empty for loops #3965
Copy link
Copy link
Open
Labels
dslxDSLX (domain specific language) implementation / front-endDSLX (domain specific language) implementation / front-endenhancementNew feature or requestNew feature or request
Description
What's hard to do? (limit 100 words)
currently one cannot write an empty for loop like for n in 0..0 {} in DSLX, as it produces the following typesystem error:
0004: for (i, accum) in u32:0..WIDTH {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^----------^ `u32:0..WIDTH` from `u32:0` to `u32:0` is an empty range
Note: this can happens when parametrics (or constant computed parametrics) resolve to 0 and are used in range expressions.
Current best alternative workaround (limit 100 words)
Increase the range expression by 1 and special case inside the for loop) or leverage the new const_if #3268 (otherwise it would still not typecheck) and special case the 0 case outside of the for loop.
Your view of the "best case XLS enhancement" (limit 100 words)
Just like rust https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=6e03e45ee17e40e962267f3d0b42de9f DSLX would relax errors on empty ranges.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
dslxDSLX (domain specific language) implementation / front-endDSLX (domain specific language) implementation / front-endenhancementNew feature or requestNew feature or request
Type
Projects
Status
No status