[Issue 14802] Template argument deduction depends on order of arguments

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jul 16 07:49:33 PDT 2015


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

--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com> ---
In the case of integer literal + short array, this is a different story,
because:

foo!int(1, a) and foo!short(1, a) do not both compile.

However, for double/float:

f!double(1.0, 1.0f) and f!float(1.0, 1.0f) both compile.

Decision is necessarily arbitrary because both can compile. To make the
decision "consistent" is not necessarily a bug fix, I can see how the compiler
is free to arbitrarily decide which type to use.

However, I'll note that in other cases, the compiler prefers one over the
other:

// both double[]
auto arr = [1.0, 1.0f];
auto arr2 = [1.0f, 1.0];

// both double
auto x = true ? 1.0 : 1.0f;
auto x2 = true ? 1.0f : 1.0;

same for uint vs. int

--


More information about the Digitalmars-d-bugs mailing list