[Issue 19084] Symbol not resolved in string mixin in template struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Aug 24 13:29:25 UTC 2018


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

--- Comment #3 from Jonathan Marler <johnnymarler at gmail.com> ---

struct Bar(T) {
    mixin("T foo;");
}

T in this case is not a "symbol name string", it is an alias to a symbol.  But
don't be confused, you can't actually create T with an alias, meaning `alias T
= Foo` won't work.  You have to use the fully qualified name of `Foo` but
because `Foo` is inside a unittest, it's prvate and you cannot access it.  The
only way to access the type is if the code inside unittest "passes" the type
alias to you through a template type parameter:

unittest
{
    struct Foo { }
    Bar!Foo bar;  // passing Foo to Bar so it can access it
}

// out here we cannot access Foo because it is private to the unittest
// the only way we can access it is if code inside of unittest passes it
// us through a template type parameter

--


More information about the Digitalmars-d-bugs mailing list