language
language copied to clipboard
Not accurate specification of `for` loop
Please see Dart specification 18.6.1. For loop
Execution of a for statement of the form
for (var v = e; c; e) s
proceeds as follows: Ifc
is empty then letc
be true otherwise letc'
bec
. First the variable declaration statementvar v = e
is executed.
Why only for (var v = e; ...) s
form is mentioned? What about for (int v = e;...)
or int i; for(i = 0; ...)
forms? Or the following
int i = -1;
g() {i = 0;}
for (g(); i < 2; i++) {
print(i);
}
Seems that this section should be rewritten.
Please also see https://github.com/dart-lang/sdk/issues/49495
That is true, the for-loop section really needs a rewrite. Cf. https://github.com/dart-lang/language/issues/862 and https://github.com/dart-lang/language/issues/1951.