Lambda in UDA - undocumented behavior

Andrey Zherikov andrey.zherikov at gmail.com
Sat Jan 20 01:16:45 UTC 2024


I was looking at dmd source code and found an undocumented 
behavior:
```d
@a=>7 int b;
pragma(msg, __traits(getAttributes, b)); // AliasSeq!((a) => 7)
```
[D 
grammar](https://dlang.org/spec/grammar.html#UserDefinedAttribute) allows lambda in UDA only inside parenthesis:
```d
@(a=>7) int b;
pragma(msg, __traits(getAttributes, b)); // AliasSeq!((a) => 7)
```

So is this a bug in compiler or in grammar documentation?


More information about the Digitalmars-d mailing list