www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23375] New: enum is not considered global mutable state

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

          Issue ID: 23375
           Summary: enum is not considered global mutable state
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: qs.il.paperinik gmail.com

An enum of slice of class can be mutated and it can be mutated even in a `pure`
function.

Example:

    class C
    {
        string s;
        this(string a) pure  safe nothrow  { s = a; }
    }

    enum C[] cs = [ new C("a"), new C("b") ];

    void f() pure  safe  nogc nothrow
    {
        cs[0].s = "c";
    }

--
Sep 26 2022