www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Struct destructor in a with block

reply "Tofu Ninja" <emmons0 purdue.edu> writes:
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?
Feb 02 2015
parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
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
Feb 02 2015
parent "Tofu Ninja" <emmons0 purdue.edu> writes:
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...
Feb 02 2015