[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
Mon Mar 28 13:06:20 UTC 2022


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

Iain Buclaw <ibuclaw at gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |ibuclaw at gdcproject.org
         Resolution|FIXED                       |---

--- Comment #7 from Iain Buclaw <ibuclaw at gdcproject.org> ---
Related test still fails though.

struct S10666
{
    int val;
    ~this() {}
}


void foo10666(S10666 s1)
{
    // Error: s1 has scoped destruction, cannot build closure.
    auto f1 = (){ return () => s1.val; }();

    enum r1 = __traits(compiles, {
        auto f1 = (){ return () => s1.val; }(); 
    });
    static assert(!r1); // Error: static assert:  `!r1` is false
}

--


More information about the Digitalmars-d-bugs mailing list