null literal requires an explicit cast, in order to be considered a match for a parameter of nullable type.
----
class C
{
}
void foo(T)(T x, C c) // C - a nullable type
{
}
void main()
{
foo(1, null); // fails
foo(1, cast(C)null); // ok
}
----
test.d(17): template Test.foo(T) does not match any function template declaration
Comment #1 by Jesse.K.Phillips+D — 2011-07-18T18:06:50Z
Here is a simple example with string.
----
void main() {
example(null);
}
void example()(string[] foo) {
}
----
test.d(3): Error: template test.example() does not match any function
template declaration
test.d(3): Error: template test.example() cannot deduce template function
from argument types !()(void*)
Comment #2 by yebblies — 2011-07-18T20:31:16Z
Related to issue 2367 (and fixed by that patch)
Comment #3 by yebblies — 2011-07-18T21:33:16Z
Or maybe it's bug 4953
Comment #4 by k.hara.pg — 2011-12-27T00:21:55Z
By fixing issue 5416 (dmd2.057 and later), null literal works as expected in IFTI.