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



--- Comment #2 from osa8...@gmail.com 2010-10-26 15:17:04 PDT ---
> A related program shows a different outcome:
>     Bar a;
>     Foo f;
>     a = f; // Access violation!

This is expected. 'a' is an uninitialized, and attempt to assign to a Foo part
of null instance causes access violation. This is no different from

  Bar a;
  a.foo_ = Foo();

"Partial" assignment of Foo to a valid Bar instance is fine and works as
expected:
-----
struct Foo { int x; }
class Bar {
    Foo foo_;
    alias foo_ this;
    int y;
}
void main() {
    Bar a = new Bar;
    a.x = 1;
    a.y = 42;
    assert( a.foo_.x == 1 && a.y == 42 );
    a = Foo( 2 );
    assert( a.foo_.x == 2 && a.y == 42 );
}
-----

My problem is only with special treatment of null: I want to nullify local
reference to a Bar instance, not change Bar or Foo inside it.

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

Reply via email to