File tree Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Expand file tree Collapse file tree 1 file changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -518,8 +518,8 @@ foreach (n; arr) // ok, n is an int
518
518
--------------
519
519
)
520
520
$(P
521
- The aggregate must be * loop invariant* , meaning that
522
- elements cannot be added or removed from the aggregate
521
+ The aggregate must be loop invariant, meaning that
522
+ elements to the aggregate cannot be added or removed from it
523
523
in the *NoScopeNonEmptyStatement*.
524
524
)
525
525
@@ -996,24 +996,21 @@ $(CONSOLE
996
996
997
997
$(H3 $(LNAME2 foreach_restrictions, Foreach Restrictions))
998
998
999
- $(UNDEFINED_BEHAVIOR The aggregate itself must not be resized, reallocated, free'd,
999
+ $(P The aggregate itself must not be resized, reallocated, free'd,
1000
1000
reassigned or destructed
1001
1001
while the foreach is iterating over the elements.
1002
1002
)
1003
1003
1004
1004
--------------
1005
- int[] a, b ;
1006
- ...
1007
- foreach (int v ; a)
1005
+ int[] a;
1006
+ int[] b;
1007
+ foreach (int i ; a)
1008
1008
{
1009
- a ~= 4; // error
1010
- a.length += 10; // error
1011
-
1012
1009
a = null; // error
1010
+ a.length += 10; // error
1013
1011
a = b; // error
1014
1012
}
1015
- a ~= 4; // OK
1016
- a = null; // OK
1013
+ a = null; // ok
1017
1014
--------------
1018
1015
1019
1016
$(H3 $(LEGACY_LNAME2 ForeachRangeStatement, foreach-range-statement, Foreach Range Statement))
You can’t perform that action at this time.
0 commit comments