Bug 2122 – Scope object from a mixin destroyed immediately
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-05-23T12:25:00Z
Last change time
2015-06-09T01:19:25Z
Assigned to
bugzilla
Creator
bartosz
Comments
Comment #0 by bartosz — 2008-05-23T12:25:54Z
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