Bug 19081 – Can't declare enum with UDA at statement level

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-07-12T15:15:39Z
Last change time
2018-07-17T10:59:21Z
Assigned to
No Owner
Creator
Yuxuan Shui

Comments

Comment #0 by yshuiv7 — 2018-07-12T15:15:39Z
Example: @(1) enum A { A } // Fine struct T1 { @(1) struct T2 {} // Fine @(1) enum A { A } // Fine } debug { @(1) enum Op { Add, Sub } // Fine } unittest { @(1) struct X { } // Fine @(1) enum Op { Add, Sub } // Not fine ?! } void main() {} https://godbolt.org/g/TSQeYW
Comment #1 by yshuiv7 — 2018-07-12T17:29:01Z
This is because, in
Comment #2 by yshuiv7 — 2018-07-12T17:31:41Z
This is because, at statement level, enum is also a storage class: enum X = 10; I wonder why declaring enum without a UDA works at statement level. I smell terrible hacks.
Comment #3 by github-bugzilla — 2018-07-17T10:59:20Z
Commits pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/89639f2876a72015ef4ade085293deb55c2f459f Fix issue 19081 - defining enum with UDA at statements level Don't treat 'enum' as storage class if it's followed by ':', '{' or an identifier and '{'. https://github.com/dlang/dmd/commit/4a2805d4986ee85899abeb7903f523526603291c Merge pull request #8492 from yshui/uda-enum Fix issue 19081 - defining enum with UDA at statements level