Bug 20503 – incorrect grammar specification for @ attributes in declarations

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dlang.org
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-14T21:05:08Z
Last change time
2021-07-06T10:36:51Z
Keywords
spec
Assigned to
No Owner
Creator
Dennis
See also
https://issues.dlang.org/show_bug.cgi?id=5803

Comments

Comment #0 by dkorpel — 2020-01-14T21:05:08Z
These do compile: ``` void foo() @safe @nogc {} void bar() @("uda") {} ``` According to the spec, only const, immutable, inout, return, shared, nothrow, pure and @property are allowed after the parameter list. https://dlang.org/spec/grammar.html#MemberFunctionAttribute These also compile: ``` @safe foo() {} @("uda") foo() {} @("uda") x = 3, y = 3; ``` `AtAttribute` is not in `StorageClass` (which is used in AutoDeclaration and AutoFuncDeclaration), so according to the spec these are not allowed. https://dlang.org/spec/grammar.html#AutoFuncDeclaration https://dlang.org/spec/grammar.html#AutoDeclaration I think adding AtAttribute to MemberFunctionAttribute and StorageClass would fix this but I haven't checked what the implementation exactly permits and disallows.
Comment #1 by dkorpel — 2021-07-06T10:36:51Z