[Issue 21170] New: Can not instantiate a class instance using inout constructor.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 17 09:13:28 UTC 2020


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

          Issue ID: 21170
           Summary: Can not instantiate a class instance using inout
                    constructor.
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: alexandru.ermicioi at gmail.com

Kinda silly that you can't create mutable/immutable objects using inout
constructor. For some reason const one works.

Example:
-----
import std;

class Silly {
    this() inout {
    }
}

void main()
{
    auto s = new Silly();
    auto cs = new const Silly();
    auto iss = new immutable Silly();
}
-----

Error:
-----
onlineapp.d(10): Error: inout constructor onlineapp.Silly.this creates inout
object, not mutable
onlineapp.d(12): Error: inout constructor onlineapp.Silly.this creates inout
object, not immutable
-----

Expected:
first & second error to not be at all here, since those are also part of inout
constructor's job.

--


More information about the Digitalmars-d-bugs mailing list