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.
Comment #1 by k.hara.pg — 2011-09-09T07:34:42Z
Comment #2 by bugzilla — 2011-09-12T23:02:53Z
Comment #3 by yebblies — 2011-09-17T03:57:26Z
*** Issue 6684 has been marked as a duplicate of this issue. ***
Comment #4 by k.hara.pg — 2011-10-04T13:22:11Z
*** Issue 6378 has been marked as a duplicate of this issue. ***