www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19273] New: immutable on a class declaration doesn't cause


          Issue ID: 19273
           Summary: immutable on a class declaration doesn't cause
                    references of that type to be immutable
           Product: D
           Version: D2
          Hardware: Other
                OS: Other
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: doob me.com

This issue is best describe by an example:

immutable struct Foo {}
immutable class Bar {}

void main()
    Foo foo;
    Bar bar;

    static assert(is(typeof(foo) == immutable(Foo)));
    static assert(is(typeof(bar) == Bar));

I don't expect the above code to compile, but it does. The question is why the
type of "bar" is not immutable(Bar) when that's the case for "foo"? DMD

Sep 28 2018