[Issue 15347] New: error message for converting return value with ctor/dtor is horrible
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Nov 16 14:47:52 PST 2015
https://issues.dlang.org/show_bug.cgi?id=15347
Issue ID: 15347
Summary: error message for converting return value with
ctor/dtor is horrible
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: diagnostic
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schveiguy at yahoo.com
Simple example:
struct S(T)
{
T *t;
immutable(S) foo(T* x) { return S(x);}
}
S!int s;
The error message is as follows:
Error: cannot implicitly convert expression (S(x)) of type S!int to
immutable(S!int)
Reasonable, straightforward message. But it starts breaking down as we add ctor
and dtor:
struct S(T)
{
T *t;
this(T *x) { t = x;}
immutable(S) foo(T* x) { return S(x);}
}
Error: cannot implicitly convert expression (S(null).this(x)) of type S!int to
immutable(S!int)
Not sure where the S(null).this(x) comes from. Add a dtor and it's even worse:
struct S(T)
{
T *t;
this(T *x) { t = x;}
~this() {}
immutable(S) foo(T* x) { return S(x);}
}
Error: cannot implicitly convert expression (( S!int __slS51 = S(null);
, __slS51).this(x)) of type S!int to immutable(S!int)
That carriage return is actually in the output. I don't even think that's valid
D code (semicolon followed by comma).
All three of these should look like the first one.
Note that just a dtor does not affect the output.
Tested as far back as 2.067.1
--
More information about the Digitalmars-d-bugs
mailing list