Currently this doesn't compile: while (auto parent = foo.parent) { foo = parent; } Error: expression expected, not 'auto' This is useful to replace this kind of loop (assume foo is a class object that has a 'parent' field): while (true) { if (auto parent = foo.parent) { // do something with parent foo = parent; // switch to next parent } else { break; } } with the simpler: while (auto parent = foo.parent) { // do something with parent foo = parent; // switch to next parent } Currently `if` statements already allow this syntax, so it seems natural to extend this to `while` loops.
note that this can be implemented with a simple rewrite rule.
*** This issue has been marked as a duplicate of issue 5432 ***