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

          Issue ID: 20169
           Summary: Cannot allocate immutable class on the stack with
                    scope
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

----------------------
class Foo {
    this(int i) immutable {}
}

void main() {
    scope foo = new immutable Foo(42);
}
-----------------------

Fails to compile with:

huh.d(6): Error: cannot modify immutable expression foo


It works as expected if `auto` is used instead of `scope`.

--

Reply via email to