www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20308] New: frame access regression

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

          Issue ID: 20308
           Summary: frame access regression
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: john.loughran.colvin gmail.com

template OverloadSet(Args ...)
{
    static foreach (Arg; Args)
        alias overloads = Arg;
}

struct S(handlers ...)
{
    static struct HandlerGroup
    {
        static opCall(int a)
        {
            return OverloadSet!(handlers).overloads(a);
        }
    }

    static auto ref call(alias f)()
    {
                return f(HandlerGroup.init);
    }
}

void main()
{
        assert(
                S!((double z) => z, y => y)
                        .call!(r => r(1))()
        == 1);
}

onlineapp.d(13): Error: static function onlineapp.main.S!(function (double z)
=> z, (y) => y).S.HandlerGroup.opCall cannot access frame of function D main
onlineapp.d(26): Error: template instance `onlineapp.main.S!(function (double
z) => z, (y) => y)` error instantiating

The regression was introduced by https://github.com/dlang/dmd/pull/10214 and
was released in 2.087.1

--
Oct 20 2019