Skip to content

Commit 721ac37

Browse files
ntreldkorpel
andauthored
[spec] foreach_reverse with a delegate is an error (#3813)
* [spec] `foreach_reverse` with a delegate is an error Update for dlang/dmd#16418. Co-authored-by: Dennis <[email protected]>
1 parent 15b06c6 commit 721ac37

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

spec/statement.dd

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,8 @@ $(H4 $(LNAME2 front-seq, Multiple Element Values))
984984

985985
$(H3 $(LNAME2 foreach_over_delegates, Foreach over Delegates))
986986

987-
$(P If $(I ForeachAggregate) is a delegate, the type signature of
988-
the delegate is of the same as for
987+
$(P If $(I ForeachAggregate) is a delegate, the type signature and
988+
behavior of the delegate is the same as for
989989
$(RELATIVE_LINK2 foreach_over_struct_and_classes, opApply). This enables
990990
many different named looping strategies to coexist in the same
991991
class or struct.)
@@ -996,7 +996,7 @@ $(SPEC_RUNNABLE_EXAMPLE_RUN
996996
--------------
997997
// Custom loop implementation, that iterates over powers of 2 with
998998
// alternating sign. The foreach loop body is passed in dg.
999-
int myLoop(int delegate(int) dg)
999+
int myLoop(scope int delegate(int) dg)
10001000
{
10011001
for (int z = 1; z < 128; z *= -2)
10021002
{
@@ -1019,11 +1019,8 @@ $(SPEC_RUNNABLE_EXAMPLE_RUN
10191019
--------------
10201020
)
10211021

1022-
$(P $(B Note:) When $(I ForeachAggregate) is a delegate, the compiler
1023-
does not try to implement reverse traversal of the results returned by
1024-
the delegate when $(D foreach_reverse) is used. This may result in code
1025-
that is confusing to read. Therefore, using $(D foreach_reverse) with a
1026-
delegate is now deprecated, and will be rejected in the future.)
1022+
$(P $(D foreach_reverse) with a delegate is an error.)
1023+
10271024

10281025
$(H3 $(LNAME2 foreach_over_tuples, Foreach over Sequences))
10291026

0 commit comments

Comments
 (0)