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

          Issue ID: 24248
           Summary: const constructor with mutable target gives wrong
                    error message
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: n...@geany.org

struct S2
{
    this(int) const {}
    int* i;
}

void main()
{
    S2 s2 = S2(5);
}

Error: constructor `const_ctor.S2.this(int __param_0) const` is not callable
using argument types `(int)`

Which is confusing as the only parameter the user sees does actually match
correctly. It should instead say:

Error: `const` constructor `const_ctor.S2.this` cannot construct a mutable
object

Which is the style of wording you get if the constructor is declared as
immutable (actually after issue #24247 is fixed, but even without that the
status quo is for immutable is much better than for const).

PR incoming.

--

Reply via email to