[Issue 7019] implicit constructors are inconsistently allowed
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Jun 24 02:30:16 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=7019
--- Comment #16 from Denis Shelomovskij <verylonglogin.reg at gmail.com> ---
(In reply to Kenji Hara from comment #15)
> (In reply to Denis Shelomovskij from comment #14)
> > static assert(!__traits(compiles, { S2 s2 = { 5 }; })); // fails
> > static assert(!__traits(compiles, { S2 s2 = { s: 5 }; })); // fails
>
> These are expected behavior.
> The target type of the argument '5' can be determined to S, so implicit
> constructor call is handled.
How does `S2 s2 = { 5 }` differ from `f(5)` or `S2 s2 = S2(5)`? IMO the only
clean rule is:
"Implicit conversion exists iff target type is explicitly stated."
What is wrong with this rule? What rules and why are preferred?
--
More information about the Digitalmars-d-bugs
mailing list