January 14, 2020 [Issue 20503] New: incorrect grammar specification for @ attributes in declarations | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20503 Issue ID: 20503 Summary: incorrect grammar specification for @ attributes in declarations Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: spec Severity: normal Priority: P1 Component: dlang.org Assignee: nobody@puremagic.com Reporter: dkorpel@live.nl 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. -- |
Copyright © 1999-2021 by the D Language Foundation