Bug 16178 – Can't alias a mixin

Status
RESOLVED
Resolution
INVALID
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-06-17T00:09:00Z
Last change time
2016-07-27T19:36:52Z
Assigned to
nobody
Creator
hbaelx

Comments

Comment #0 by hbaelx — 2016-06-17T00:09:46Z
A brief sample: alias foo = mixin(bar!T); where var!T returns the name of a valid variable, and thus mixin' it provides access to said variable. The previous code won't compile: Error: basic type expected, not mixin There is a known workaround around this issue: alias hack(alias a) = a; alias foo = hack!(mixin(bar!T)); But clearly it shouldn't have to be done like this.
Comment #1 by kapblc — 2016-06-17T17:12:18Z
вот так ещё можно mixin("alias foo = " ~ bar!T ~ ";");
Comment #2 by hbaelx — 2016-07-27T19:34:36Z
After more experience with Phobos, I realized this is apparently not an issue and is intended to be done with the Alias template from the std.meta module. Rejecting my own issue I guess. The working solution: import std.meta : Alias; alias foo = Alias!(mixin(bar!T));