Skip to content

Commit f6dec52

Browse files
Remove special case of __traits(parameters) in foreach (#3255)
The trait now consistently returns the function parameters
1 parent a6346d7 commit f6dec52

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

spec/traits.dd

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,11 +1037,6 @@ $(H3 $(GNAME parameters))
10371037
$(P If the function is nested, the parameters returned are those of the
10381038
inner function, not the outer one.)
10391039

1040-
$(P When used inside a $(DDSUBLINK spec/statement, foreach-statement,
1041-
`foreach` statement) that calls an $(DDSUBLINK spec/statement,
1042-
foreach_over_struct_and_classes, `opApply` overload), the parameters
1043-
returned are those of the delegate passed to `opApply`.)
1044-
10451040
---
10461041
int add(int x, int y)
10471042
{
@@ -1083,13 +1078,12 @@ $(H3 $(GNAME parameters))
10831078
{
10841079
foreach(idx; 0..5)
10851080
{
1086-
// foreach does not call opApply
10871081
static assert(is(typeof(__traits(parameters)) == AliasSeq!(C, int)));
10881082
}
10891083
foreach(idx, elem; c)
10901084
{
1091-
// foreach calls opApply
1092-
static assert(is(typeof(__traits(parameters)) == AliasSeq!(size_t, C)));
1085+
// __traits(parameters) sees past the delegate passed to opApply
1086+
static assert(is(typeof(__traits(parameters)) == AliasSeq!(C, int)));
10931087
}
10941088
}
10951089
---

0 commit comments

Comments
 (0)