www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19625] New: [Reg 2.066] module-level static template struct


          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 puremagic.com
          Reporter: john.loughran.colvin 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/

Jan 28