Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lambda as UDA is valid but spec requires brackets #4137

Open
dlangBugzillaToGithub opened this issue Jan 20, 2024 · 1 comment
Open

Lambda as UDA is valid but spec requires brackets #4137

dlangBugzillaToGithub opened this issue Jan 20, 2024 · 1 comment

Comments

@dlangBugzillaToGithub
Copy link

Richard (Rikki) Andrew Cattermole reported this on 2024-01-20T01:25:08Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=24346

CC List

Description

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.
@dlangBugzillaToGithub
Copy link
Author

hsteoh commented on 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.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant