[Issue 19625] New: [Reg 2.066] module-level static template struct can't take alias to a delegate

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jan 28 18:10:17 UTC 2019


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

          Issue ID: 19625
           Summary: [Reg 2.066] module-level static template struct can't
                    take alias to a delegate
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: john.loughran.colvin at gmail.com

static struct S(alias f)
{
    int foo() { return f(); }
}

void main()
{
    int a;
    int b = S!(() => a)().foo;
}

Error: function onlineapp.main.S!(delegate () => a).S.foo cannot access frame
of function D main

Removing the `static` causes it to compile fine, but why does static do
anything at module scope? I tried to read the docs but they didn't say much on
the topic.

This was fixed in https://github.com/dlang/dmd/pull/2794 and then broken again
in the revert https://github.com/dlang/dmd/pull/3884/

--


More information about the Digitalmars-d-bugs mailing list