Bug 23326 – invariant syntax is inconsistently strict for annotations

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-09-04T16:30:51Z
Last change time
2024-12-13T19:24:21Z
Assigned to
No Owner
Creator
Ali Cehreli
Moved to GitHub: dmd#20144 →

Comments

Comment #0 by acehreli — 2022-09-04T16:30:51Z
struct S { void foo() @nogc {} // fine @nogc void foo() {} // fine @nogc invariant() {} // fine invariant() @nogc {} /* compilation errors: Error: statement expected to be `{ }`, not `@` Error: basic type expected, not `{` Error: declaration expected, not `{` */ } That example uses @nogc but it's the same with other attributes like @safe, pure, etc.
Comment #1 by dkorpel — 2022-09-04T19:21:26Z
Notably the same applies to unittest: ``` @nogc unittest {} // fine unittest @nogc {} // compilation errors with -unittest ```
Comment #2 by nick — 2022-09-05T09:03:56Z
Also for the override attribute: override void f() {} // ok void f() override {} // error
Comment #3 by robert.schadek — 2024-12-13T19:24:21Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20144 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB