Bug 6630 – Assigning null to class with nested alias this class is misinterpreted
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
FreeBSD
Creation time
2011-09-08T16:04:00Z
Last change time
2011-10-04T13:22:11Z
Keywords
patch, wrong-code
Assigned to
nobody
Creator
code
Comments
Comment #0 by code — 2011-09-08T16:04:03Z
version = Stage1;
version = Stage2;
class A {
this() { b = new B(); }
B b;
alias b this;
}
class B {
}
void fun(A a)
{
a = null;
version (Stage1)
assert(a is null);
}
void main() {
auto a = new A;
assert(a.b !is null);
fun(a);
assert(a !is null);
version (Stage2)
assert(a.b !is null);
}
---
If you want to nullify an reference to a and assign null to it,
instead a's reference to b is nullified.