Bug 16140 – while(auto x = y) does not behave like if(auto x = y)

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-06-08T16:30:28Z
Last change time
2021-04-09T06:59:09Z
Keywords
pull
Assigned to
No Owner
Creator
Sophie
See also
https://issues.dlang.org/show_bug.cgi?id=13526, https://issues.dlang.org/show_bug.cgi?id=11070

Comments

Comment #0 by meapineapple — 2016-06-08T16:30:28Z
While loops ought to support the same syntax as conditionals for assigning the result of an expression to a value scoped to that loop. void main(){ if(auto value = 1){} // compiles while(auto value = 1){} // expression expected, not 'auto' }
Comment #1 by ketmar — 2016-06-09T07:01:02Z
*** This issue has been marked as a duplicate of issue 13526 ***
Comment #2 by ketmar — 2016-06-09T07:01:39Z
oops. sorry, i misread "with" as "while"... ;-)
Comment #3 by deadalnix — 2021-03-01T15:19:45Z
+1 This shouldn't be too difficult to fix and would make some code much nicer.
Comment #4 by dlang-bot — 2021-03-02T16:23:27Z
@RazvanN7 created dlang/dmd pull request #12246 "Fix Issue 16140 - while(auto x = y) does not behave like if(auto x = y)" fixing this issue: - Fix Issue 16140 - while(auto x = y) does not behave like if(auto x = y) https://github.com/dlang/dmd/pull/12246
Comment #5 by dlang-bot — 2021-03-10T08:42:33Z
@RazvanN7 created dlang/dlang.org pull request #2977 "Spec change for Issue 16140" mentioning this issue: - Spec change for Issue 16140 PR: https://github.com/dlang/dmd/pull/12246 https://github.com/dlang/dlang.org/pull/2977
Comment #6 by dlang-bot — 2021-03-10T12:01:56Z
dlang/dlang.org pull request #2977 "Spec change for Issue 16140" was merged into master: - 9bd20fae46bde6d50ff9efef3b080d8fd550aab0 by Razvan Nitu: Spec change for Issue 16140 PR: https://github.com/dlang/dmd/pull/12246 https://github.com/dlang/dlang.org/pull/2977
Comment #7 by dlang-bot — 2021-03-13T14:51:53Z
dlang/dmd pull request #12246 "Fix Issue 16140 - while(auto x = y) does not behave like if(auto x = y)" was merged into master: - 43aa3eeecefb08e1ea5496e12eb9e1feffc54c89 by RazvanN7: Fix Issue 16140 - while(auto x = y) does not behave like if(auto x = y) https://github.com/dlang/dmd/pull/12246
Comment #8 by razvan.nitu1305 — 2021-04-09T06:59:09Z
*** Issue 21811 has been marked as a duplicate of this issue. ***