Comment #0 by andrej.mitrovich — 2014-01-24T12:35:52Z
-----
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.
Comment #1 by nick — 2023-08-26T11:26:13Z
Still happens with recent git.
Comment #2 by b2.temp — 2024-11-11T18:25:09Z
The bug is much more specific than suggested by the summary.
1. it is limited to classes because the following works
```
struct S(T){}
void v(T)(S!T* a, S!T* b) {}
void main()
{
S!int* a;
v(a,null);
}
```
2. it limited to classes templates because the following works
```
class S{}
void v(T)(T a, T b) {}
void main()
{
S a;
v(a,null);
}
```
Comment #3 by robert.schadek — 2024-12-13T18:16:11Z