www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Lambda in UDA - undocumented behavior

reply Andrey Zherikov <andrey.zherikov gmail.com> writes:
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?
Jan 19
parent reply "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
https://issues.dlang.org/show_bug.cgi?id=24346
Jan 19
parent reply Andrey Zherikov <andrey.zherikov gmail.com> writes:
On Saturday, 20 January 2024 at 01:25:16 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
 https://issues.dlang.org/show_bug.cgi?id=24346
Does this mean it's a bug? :) tbh I'd like to try fixing it since I'm with that code atm.
Jan 19
parent "Richard (Rikki) Andrew Cattermole" <richard cattermole.co.nz> writes:
On 20/01/2024 2:26 PM, Andrey Zherikov wrote:
 On Saturday, 20 January 2024 at 01:25:16 UTC, Richard (Rikki) Andrew 
 Cattermole wrote:
 https://issues.dlang.org/show_bug.cgi?id=24346
Does this mean it's a bug? :) tbh I'd like to try fixing it since I'm with that code atm.
There is a bug here yes. The problem is it might be a compiler bug, or it could be a specification bug. Generally we consider the implementation to win on differences between the compiler and specification for issues such as this. Given that it does not appear to be harmful, no need to change the compiler :)
Jan 19