On Thursday, 23 August 2018 at 19:48:19 UTC, Robert burner Schadek wrote:
It is still rough around the corners and https://issues.dlang.org/show_bug.cgi?id=19084 gives me somewhat of a hard time, but give it try and scream at me because it is not nogc.

I've posted a comment on issue 19084 but I'll post the response here as well.

This is not supposed to compile. I've actually run into this before, but using T.stringof to mixin code for a type name is not supported. When I've asked about adding support for this, no one was interested. I tried to find my forum posts on this but the post is so old I couldn't find it in search.

What happens is you mixin the string "Foo", but that type doesn't mean anyting in the scope of Bar. The actual type name is something like "__unittest__20.Foo", however, even if you got the fully qualified type name it won't work because the type is private and can't be accessed outside of the unittest using the symbol name. You have to access the type by "alias".

The `bitfields` function in phobos suffers from this same problem and I created a PR in phobos to add bitfields2 to workaround this issue by using a "mixin template" instead of a normal "mixin":

https://github.com/dlang/phobos/pull/5490

[QUOTE FROM THE PR]
The main advantage of bitfields2 is that it is able to reference the field types by alias, whereas the current implementation converts each field type alias to a string and then mixes in the type name.


I know the example you've provided is contrived so I'm not sure how to help you with your exact situation. Maybe I can help you find a solution with a bit more detail?

Reply via email to