www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17799] New: Disallow enum with indirections

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 puremagic.com
          Reporter: qs.il.paperinik 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

--
Sep 01