Skip to content

Commit e53fa79

Browse files
authored
Improve parameter UDA spec (#4304)
1 parent 8cade94 commit e53fa79

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

spec/attribute.dd

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,9 +1168,13 @@ struct Bar
11681168
}
11691169
---
11701170

1171-
$(P A function parameter can have a UDA:)
1171+
$(P A function parameter can have a UDA. Parameters do not inherit UDAs from outside the parameter list.)
11721172
---
1173-
void f(@(3) int p);
1173+
@2 void f(@3 int p)
1174+
{
1175+
pragma(msg, __traits(getAttributes, p)); // prints AliasSeq!(3)
1176+
}
1177+
11741178
---
11751179

11761180
$(H3 $(LNAME2 getAttributes, `__traits(getAttributes)`))
@@ -1182,7 +1186,7 @@ $(H3 $(LNAME2 getAttributes, `__traits(getAttributes)`))
11821186

11831187
---
11841188
@('c') string s;
1185-
pragma(msg, __traits(getAttributes, s)); // prints tuple('c')
1189+
pragma(msg, __traits(getAttributes, s)); // prints AliasSeq!('c')
11861190
---
11871191

11881192
$(P
@@ -1202,7 +1206,7 @@ enum e = 7;
12021206

12031207
alias TP = __traits(getAttributes, foo);
12041208

1205-
pragma(msg, TP); // prints tuple(3, 4, 7, (SSS))
1209+
pragma(msg, TP); // prints AliasSeq!(3, 4, 7, (SSS))
12061210
pragma(msg, TP[2]); // prints 7
12071211
---
12081212
)
@@ -1220,8 +1224,8 @@ TP[3] a; // a is declared as an SSS
12201224
)
12211225

12221226
---
1223-
pragma(msg, __traits(getAttributes, a)); // prints tuple()
1224-
pragma(msg, __traits(getAttributes, typeof(a))); // prints tuple("hello")
1227+
pragma(msg, __traits(getAttributes, a)); // prints AliasSeq!()
1228+
pragma(msg, __traits(getAttributes, typeof(a))); // prints AliasSeq!("hello")
12251229
---
12261230

12271231
$(H3 $(LNAME2 uda-usage, Usage))
@@ -1262,17 +1266,17 @@ $(SPEC_RUNNABLE_EXAMPLE_COMPILE
12621266
}
12631267

12641268
pragma(msg, __traits(getAttributes, Outer!int.S));
1265-
// prints tuple("foo")
1269+
// prints AliasSeq!("foo")
12661270
pragma(msg, __traits(getAttributes, Outer!int.S.x));
1267-
// prints tuple()
1271+
// prints AliasSeq!()
12681272
pragma(msg, __traits(getAttributes, Outer!int.y));
1269-
// prints tuple("foo")
1273+
// prints AliasSeq!("foo")
12701274
pragma(msg, __traits(getAttributes, Outer!int.fun));
1271-
// prints tuple("foo")
1275+
// prints AliasSeq!("foo")
12721276
pragma(msg, __traits(getAttributes, Outer!int.Inner));
1273-
// prints tuple("foo", "bar")
1277+
// prints AliasSeq!("foo", "bar")
12741278
pragma(msg, __traits(getAttributes, Outer!int.Inner!int.z));
1275-
// prints tuple("foo", "bar")
1279+
// prints AliasSeq!("foo", "bar")
12761280
---
12771281
)
12781282

0 commit comments

Comments
 (0)