www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24247] New: Improve constructor not callable using $modifier

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

          Issue ID: 24247
           Summary: Improve constructor not callable using $modifier
                    object error
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: nick geany.org

struct S1
{
    this(ref const S1 s) immutable {
    }
    int i;
}

void main()
{
    const(S1) s1;
    S1 ms1 = s1;
}

Error: `immutable` method `immutable_ctor.S1.this` is not callable using a
mutable object

This should be changed to:

Error: `immutable` constructor `immutable_ctor.S1.this` cannot construct a
mutable object

--
Nov 16 2023