www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18289] New: static function and access frame

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

          Issue ID: 18289
           Summary: static function and access frame
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: sascha.orlov gmail.com

According to the discussion here: 
https://forum.dlang.org/thread/qknxjxzbaowmsjdngvli forum.dlang.org
the following code should compile, but it does not. 

void main() // line 1
{
    auto s = S();
    auto t = T!s(); // line 4
    t.fun;
}
struct S { void fun(){} }
struct T(alias s){ static fun() { s.fun; } } // line 8

The error is: 
source/app.d(8,35): Error: static function app.main.T!(s).T.fun cannot access
frame of function D main
source/app.d(4,14): Error: template instance app.main.T!(s) error instantiating

--
Jan 23 2018