www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21811] New: Unable to use IfCondition as expression in while


          Issue ID: 21811
           Summary: Unable to use IfCondition as expression in while
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: mrjnewt gmail.com

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

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

Apr 08 2021