D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 2394 - IFTI fails for nulls
Summary: IFTI fails for nulls
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 minor
Assignee: No Owner
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2008-10-05 04:08 UTC by Max Samukha
Modified: 2015-06-09 01:20 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Max Samukha 2008-10-05 04:08:09 UTC
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 Jesse Phillips 2011-07-18 18:06:50 UTC
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 yebblies 2011-07-18 20:31:16 UTC
Related to issue 2367 (and fixed by that patch)
Comment 3 yebblies 2011-07-18 21:33:16 UTC
Or maybe it's bug 4953
Comment 4 Kenji Hara 2011-12-27 00:21:55 UTC
By fixing issue 5416 (dmd2.057 and later), null literal works as expected in IFTI.