Bug 24346 – Lambda as UDA is valid but spec requires brackets

Status
NEW
Severity
enhancement
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-01-20T01:25:08Z
Last change time
2024-12-15T15:28:06Z
Assigned to
No Owner
Creator
Richard (Rikki) Andrew Cattermole
Moved to GitHub: dlang.org#4137 →

Comments

Comment #0 by alphaglosined — 2024-01-20T01:25:08Z
From: https://forum.dlang.org/post/[email protected] The lambda here is valid, even though it is not in a brackets. ```d @a=>7 int b; pragma(msg, __traits(getAttributes, b)); // AliasSeq!((a) => 7) ``` Should only be supported (according to specification): ```d @(a=>7) int b; pragma(msg, __traits(getAttributes, b)); // AliasSeq!((a) => 7) ``` Clarification or a compiler bug fix is needed.
Comment #1 by hsteoh — 2024-01-20T01:34:51Z
I'm inclined to say that parentheses should be required, for consistency with the single-token requirement on unparenthesized UDAs. (Cf also binary `!` syntax, where the unparenthesized version also requires exactly 1 token, and in all other cases parentheses are required.)
Comment #2 by robert.schadek — 2024-12-15T15:28:06Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dlang.org/issues/4137 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB