www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2122] New: Scope object from a mixin destroyed immediately

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2122

           Summary: Scope object from a mixin destroyed immediately
           Product: D
           Version: 2.013
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: bartosz relisoft.com


I create a scope object using a mixin. When I run the program, the scope object
is destroyed immediately after construction, instead of at the end of the scope
of instantiation.
---------------
import std.stdio;
import std.string;

scope class Foo
{
        this ()
        {
                writeln ("Constructor");
        }
        ~this ()
        {
                writeln ("Destructor");
        }
}

string ScopedVar ()
{
        return "scope Foo f = new Foo;\n";
}

void main ()
{
        mixin (ScopedVar ());
        writeln ("  Inside Scope");
}
----Output----
c:\D\Work>test
Constructor
Destructor
  Inside Scope


-- 
May 23 2008
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2122


smjg iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg iname.com
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME





Cannot reproduce in DMD 1.036 or 2.019.


-- 
Nov 24 2008