Re: Destructor called twice.

2018-02-26 Thread TheFlyingFiddle via Digitalmars-d-learn
On Sunday, 25 February 2018 at 21:35:33 UTC, ketmar wrote: add postblit debug prints, and you will see. I get that it will call the postblit since it creates a temporary. What I expected though was that. auto s = S(0).foo(1); Would become something like: S s; s.__ctor(0).foo(1); But maybe

Re: Destructor called twice.

2018-02-25 Thread ketmar via Digitalmars-d-learn
add postblit debug prints, and you will see.

Destructor called twice.

2018-02-25 Thread TheFlyingFiddle via Digitalmars-d-learn
When writing some code to setup properties in a chain function manner I ran into some unexpected behavior with destructors. Example: struct S { int a, b; ref S foo(int b) { this.b = b; return this; } this(int ab) { this.a = this.b = ab;