Skip to content

Commit bf2ad3e

Browse files
committed
Move out loop invariant changes (to another PR)
1 parent 41f49bd commit bf2ad3e

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

spec/statement.dd

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,8 @@ foreach (n; arr) // ok, n is an int
518518
--------------
519519
)
520520
$(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
523523
in the *NoScopeNonEmptyStatement*.
524524
)
525525

@@ -996,24 +996,21 @@ $(CONSOLE
996996

997997
$(H3 $(LNAME2 foreach_restrictions, Foreach Restrictions))
998998

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,
10001000
reassigned or destructed
10011001
while the foreach is iterating over the elements.
10021002
)
10031003

10041004
--------------
1005-
int[] a, b;
1006-
...
1007-
foreach (int v; a)
1005+
int[] a;
1006+
int[] b;
1007+
foreach (int i; a)
10081008
{
1009-
a ~= 4; // error
1010-
a.length += 10; // error
1011-
10121009
a = null; // error
1010+
a.length += 10; // error
10131011
a = b; // error
10141012
}
1015-
a ~= 4; // OK
1016-
a = null; // OK
1013+
a = null; // ok
10171014
--------------
10181015

10191016
$(H3 $(LEGACY_LNAME2 ForeachRangeStatement, foreach-range-statement, Foreach Range Statement))

0 commit comments

Comments
 (0)