[Issue 15640] New: type inference in variadic array params not working for classes
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Feb 2 05:57:05 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15640
Issue ID: 15640
Summary: type inference in variadic array params not working
for classes
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: schuetzm at gmx.net
void test(T)(T[] args...) {
import std.stdio;
writeln(T.stringof);
}
class A { }
class B : A { }
class C : A { }
void main()
{
test(1,2,3); // int
test(4,5,6.9); // double
test(new B(), new C());
}
=> template xx.test cannot deduce function from argument types !()(B, C)
IMO `T` should be inferred as `A`. Note that the common type is already chosen
for mixed numerical types; it's an arbitrary restriction for it not to work
with classes.
--
More information about the Digitalmars-d-bugs
mailing list