Bug 21811 – Unable to use IfCondition as expression in while statement

Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-04-08T21:20:48Z
Last change time
2021-04-09T06:59:09Z
Assigned to
No Owner
Creator
Justin

Comments

Comment #0 by mrjnewt — 2021-04-08T21:20:48Z
According to the language spec, a while loop takes an IfCondition as its expression. IfConditions allow introducing a variable and assigning it but this does not actually parse in the context of a WhileStatement. The documentation for the WhileStatement explicitly mentions introducing a variable with auto as subpoint #3. WhileStatement: https://dlang.org/spec/statement.html#while-statement IfCondition: https://dlang.org/spec/statement.html#IfCondition Sample repro which fails to compile: https://run.dlang.io/is/VGwtDT
Comment #1 by razvan.nitu1305 — 2021-04-09T06:59:09Z
Hi Justin! This is an older issue, however, it was recently fixed [1], but we haven't had a release since then. If you get the latest git version of main you will have this feature. I'm gonna close this. [1] https://github.com/dlang/dmd/pull/12246 *** This issue has been marked as a duplicate of issue 16140 ***