[Issue 21692] New: Non-mutable extern(D) scope class instances cannot be created.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 8 22:29:48 UTC 2021


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

          Issue ID: 21692
           Summary: Non-mutable extern(D) scope class instances cannot be
                    created.
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: thomas.bockman at gmail.com

stackConstD and stackImutD should be allowed in the program below, just like
the other combinations. Alternatively, if there is some good reason for this
restriction, a better error message is needed, because construction is not
modification.

extern(C++) class C { }
extern(D) class D { }

void main() {
    scope stackConstC = new const(C)();
    scope stackConstD = new const(D)(); // Error: cannot modify const
expression stackConstD
    auto gcConstD = new const(D)();

    scope stackImutC = new immutable(C)();
    scope stackImutD = new immutable(D)(); // Error: cannot modify immutable
expression stackImutD
    auto gcImutD = new immutable(D)();
}

--


More information about the Digitalmars-d-bugs mailing list