Bug or intentional error?

Tofu Ninja via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 7 16:40:52 PDT 2015


On Tuesday, 7 July 2015 at 20:08:10 UTC, Daniel N wrote:
> Error: this is not in a class or struct scope
>
> mixin template NodeT1(T = typeof(this))
> {
> }
> mixin template NodeT2()
> {
>   alias T = typeof(this);
> }
>
> struct Node
> {
>   mixin NodeT1; // fail
>   mixin NodeT2; // pass
> }
Pretty sure that is expected. Default params are evaluated in the 
declaration scope, so typeof(this) is not defined in NodeT1. The 
only things that break this rule are the special identifiers like 
__FILE__ which are evaluated at the instantiation/call site.


More information about the Digitalmars-d mailing list