[Issue 6630] New: Assigning null to class with nested alias this class is misinterpreted

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Sep 8 16:04:18 PDT 2011


http://d.puremagic.com/issues/show_bug.cgi?id=6630

           Summary: Assigning null to class with nested alias this class
                    is misinterpreted
           Product: D
           Version: D2
          Platform: Other
        OS/Version: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: dawg at dawgfoto.de


--- Comment #0 from dawg at dawgfoto.de 2011-09-08 16:04:03 PDT ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list