Private alias escaping -- is this a bug?

rcorre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 25 16:51:04 PDT 2015


I ran into this infuriatingly confusing situation just now:

static assert(is(typeof(Parent.init.new Child) == Parent.Child)); 
// fine

alias P = Parent;
alias T = Parent.Child;

static assert(is(typeof(P.init.new T) == T)); // nope!

Wat???

After much confusion, I finally discovered this in my class:

class Parent {
     class Child { }
     mixin MyMixin;
}

mixin Template MyMixin() {
     private alias T = ...; // the culprit!
}

Should the private alias be able to escape? Is this a bug or 
expected behavior?

Also, is there a nice way to create template-level aliases in 
mixin templates that don't leak into the class? MyMixin generates 
multiple functions that all use T.


More information about the Digitalmars-d-learn mailing list