Hey people, I can use some help understanding why the last line produces a compile error.

```d
import std.stdio;

struct S
{
    static void foo(alias len)()
    {
        writeln(len);
    }
}

void S_foo(alias len)()
{
    writeln(len);
}

void main()
{

    const five = 5;
    S_foo!five; // Fine
    S.foo!five; // Error
}
```

The error is
```
onlineapp.d(7): Error: `static` function `onlineapp.main.foo!(5).foo` cannot access variable `five` in frame of function `D main`
onlineapp.d(19):        `five` declared here
onlineapp.d(21): Error: template instance `onlineapp.main.foo!(5)` error instantiating
```

It seems to me this should just work.

Thanks!

--Bastiaan.

Reply via email to