[Issue 12230] methods do not bind templates via alias parameter

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Mar 15 08:19:33 PDT 2016


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

--- Comment #3 from Kenji Hara <k.hara.pg at gmail.com> ---
(In reply to Vladimir Panteleev from comment #0)
> ///////////////////// test.d ////////////////////
> import std.stdio;
> 
> static template T(alias a)
> {
>     void foo() { writeln(a); }
> }
> 
> struct S
> {
>     int i = 1;
>     @property int p() { return 2; }
> 
>     alias ti = T!i; // OK
>     alias tp = T!p; // Error
> }
> /////////////////////////////////////////////////
> 
> The compiler rejects the above code, with the error:
> test.d(5,23): Error: need 'this' for 'p' of type '@property int()'

>From the long discussion in issue 11946, the static template T cannot get any
context even if the aliased symbol a is an instance member.

--


More information about the Digitalmars-d-bugs mailing list