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

Simen Kjaeraas <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #2 from Simen Kjaeraas <[email protected]> ---
Reduced example:

struct S {
    int* ip;

    this(int* t1) { }

    alias ip this;
}

unittest {
    const S t3;

    // constructor S.this(int* t1) is not callable using argument types
(const(int*))
    S t4 = t3;
}


As you say, it has to do with the use of classes (or in the above example,
pointers): const(T*) simply cannot be implicitly converted to T* without an
explicit cast - and it shouldn't.

In addition, you have a constructor that looks somewhat like the type of the
alias this, so DMD tries that when a direct conversion fails.

Removing the alias this in the above code results in the message 'cannot
implicitly convert expression t3 of type const(S) to S', which may be more
elucidating. It seems to me the correct behavior would be for DMD to print both
error messages, probably with a hint that alias this is involved in one of the
cases.

In a way, alias this is like an overload, and the error messages should reflect
this.

--

Reply via email to