[Issue 5730] __traits(compiles) does not handle "variable has scoped destruction, cannot build closure" error correctly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 16 08:30:56 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=5730

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
                 CC|                            |razvan.nitu1305 at gmail.com
         Resolution|---                         |FIXED

--- Comment #6 from RazvanN <razvan.nitu1305 at gmail.com> ---
Today this code compiles succesfully and prints "destructor":

struct S
{
    ~this()
    {
        import std.stdio;
        writeln("destructor");
    }
}

void main()
{
    S s;    
    enum error = __traits(compiles, { auto s1 = s; });
    //static assert(!error); // line 1
}

It seems that the compiler is able to allocate the closure and also track it
with the gc.

Closing as fixed.

--


More information about the Digitalmars-d-bugs mailing list