Thread overview
Struct destructor in a with block
Feb 03, 2015
Tofu Ninja
Feb 03, 2015
Ali Çehreli
Feb 03, 2015
Tofu Ninja
February 03, 2015
module main;
import std.stdio;
void main(string[] args)
{
	with(test())
	{
		foo();
	}
}
struct test
{
	void foo()
	{
		writeln("foo");
	}
	~this()
	{
		writeln("destoy");
	}
}

prints:
     destroy
     foo

Is this a bug?
February 03, 2015
On 02/02/2015 07:51 PM, Tofu Ninja wrote:
> module main;
> import std.stdio;
> void main(string[] args)
> {
>      with(test())
>      {
>          foo();
>      }
> }
> struct test
> {
>      void foo()
>      {
>          writeln("foo");
>      }
>      ~this()
>      {
>          writeln("destoy");
>      }
> }
>
> prints:
>       destroy
>       foo
>
> Is this a bug?

Yes, it's a known bug that has been fixed on git head but I can't find the bug report. :-/

The new output:

foo
destoy

Yes, without the 'r'. ;)

Ali

February 03, 2015
On Tuesday, 3 February 2015 at 05:09:55 UTC, Ali Çehreli wrote:
> Yes, it's a known bug that has been fixed on git head but I can't find the bug report. :-/

Ok cool, good to know.

> The new output:
>
> foo
> destoy
>
> Yes, without the 'r'. ;)
>
> Ali

Yeah, i noticed the typo right after I posted...