On Monday 05 October 2015 21:07, Meta wrote:

> There's a critical flaw in `scoped`. Observe:
> 
> import std.stdio;
> import std.typecons;
> 
> class A
> {
>       string name;
> 
>       this(string name)
>       {
>               this.name = name;
>               writeln("Creating A");
>       }
> 
>       ~this()
>       {
>               writeln("Destroying A");
>       }
> 
>       void hello()
>       {
>               writeln("Hello, ", this.name);
>       }
> }
> 
> void main()
> {
>       auto a1 = scoped!A("Foo");
>       a1.hello();
> 
>       A a2 = scoped!A("Foo");
>       a2.hello();
> }
> 
> 
> The output:
> 
> Creating A
> Hello, Foo
> Creating A
> Destroying A
> Destroying A
> object.Error: Access Violation

You're getting at the segfault, right? The example can then be much simpler:

----
import std.typecons;

class A
{
    void hello() {}
}

void main()
{
    A a2 = scoped!A();
    a2.hello(); /* segfault */
}
----

Reply via email to