Skip to content

Commit 5e9f375

Browse files
committed
Don't parse lambda as UDA without parentheses
This brings the compiler's behavior in line with the language spec. Fixes dlang/dlang.org#4137
1 parent cf2674f commit 5e9f375

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

compiler/src/dmd/parse.d

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,21 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
13191319

13201320
// Allow identifier, template instantiation, or function call
13211321
// for `@Argument` (single UDA) form.
1322-
AST.Expression exp = parsePrimaryExp();
1322+
AST.Expression exp;
1323+
1324+
{
1325+
const loc = token.loc;
1326+
Identifier id = token.ident;
1327+
nextToken();
1328+
if (token.value == TOK.not)
1329+
{
1330+
auto tempinst = new AST.TemplateInstance(loc, id, parseTemplateArguments());
1331+
exp = new AST.ScopeExp(loc, tempinst);
1332+
}
1333+
else
1334+
exp = new AST.IdentifierExp(loc, id);
1335+
}
1336+
13231337
if (token.value == TOK.leftParenthesis)
13241338
{
13251339
const loc = token.loc;

0 commit comments

Comments
 (0)