Bug 1717 – Template class with opAssign should be nullable
Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-12-07T22:50:00Z
Last change time
2014-02-24T15:32:16Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
vertex
Comments
Comment #0 by vertex — 2007-12-07T22:50:09Z
class Foo(T)
{
T opAssign(T v) { return v; }
}
void main()
{
auto foo = new Foo!(float)();
foo = cast(Foo!(float))null; // Works
foo = null; // Error: Can't convert null to float
}
DMD should not try to implicitly cast null to template type, but set the reference to null instead.
Comment #1 by bugzilla — 2008-01-18T12:21:36Z
This is (one reason) why opAssign for classes is getting dropped in D 2.0.