[Issue 17799] New: Disallow enum with indirections

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Fri Sep 1 23:29:30 UTC 2017


https://issues.dlang.org/show_bug.cgi?id=17799

          Issue ID: 17799
           Summary: Disallow enum with indirections
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: qs.il.paperinik at gmail.com

It is easily overseen that using enums creates a new instance every time as
enums usually have types without indirections or are immutable (e.g. strings).

  enum foo = [1,2,3];

results in

  assert(foo !is foo);

which is weird. Any other identifier that represents an array wouldn't have
this oddity.
Make it hard to use incorrectly and disallow enums that have mutable
indirections.

See https://forum.dlang.org/post/qgfdcibsepmewijgvaeb@forum.dlang.org

--


More information about the Digitalmars-d-bugs mailing list