[Issue 11986] New: IFTI type deduction / implicit conversion does not work for null literal
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Jan 24 12:35:54 PST 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11986
Summary: IFTI type deduction / implicit conversion does not
work for null literal
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: andrej.mitrovich at gmail.com
--- Comment #0 from Andrej Mitrovic <andrej.mitrovich at gmail.com> 2014-01-24 12:35:52 PST ---
-----
class C(T) { }
void foo(T)(C!T a, C!T b) { }
void main()
{
C!int c;
foo(c, null);
}
-----
test.d(10): Error: template test.foo cannot deduce function from argument types
!()(C!int, typeof(null)), candidates are:
test.d(5): test.foo(T)(C!T a, C!T b)
null should be implicitly convertible to C!T since it's a reference type. Note
that the programmer can't simply introduce another templated type parameter
since the parameter might end up being typed as typeof(null), which is
problematic. For example:
-----
class C(T) { void bar() { } }
void foo(T, T2)(C!T a, T2 b) if (is(T2 : C!T))
{
b.bar(); // Error: no property 'bar' for type 'typeof(null)'
}
void main()
{
C!int c;
foo(c, null);
}
-----
So I think the OP case is rejects-valid.
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list