typeof.stringof wrong type
David Nadlinger via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 19 08:36:02 PDT 2016
On Friday, 19 August 2016 at 15:15:55 UTC, ag0aep6g wrote:
> I think that qualifies as a bug, because fullyQualifiedName is
> supposed to be usable in code generation.
This is a misconception. Neither .stringof nor fullyQualifiedName
should *ever* be used in code generation. There is a myriad of
things that make strings unsuitable in the general case. The most
obvious reason are imports: think a type coming via an alias
parameter from a second module, which is not even important at
the point of the mixin.
Instead of trying to make .stringof work do things it will never
be able to, you need to use the type just as you would at the
point of the mixin. In this example, you would write
`mixin("typeof(a) d");`.
— David
More information about the Digitalmars-d-learn
mailing list