[Issue 21585] New: add __traits(totype, string) to convert mangled type string to an existing type
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Jan 26 08:45:05 UTC 2021
https://issues.dlang.org/show_bug.cgi?id=21585
Issue ID: 21585
Summary: add __traits(totype, string) to convert mangled type
string to an existing type
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: bugzilla at digitalmars.com
Add totype as a __trait:
---
__trait ( totype, AssignExpression )
---
AssignExpression is evaluated at compile time, and the result must be
a string. The string must be a sequence of characters representing the
mangling of an existing type. The __trait then represents that type.
For example:
---
pragma(msg, 1.mangleof); // prints `i`
__traits(totype, "i") x; // declares `x` as having type `int`
__traits(totype, "Pi") p; // declares `p` as having type `int*`
__traits(totype, 3) y; // error: `3` is not a string
__traits(totype, "#Hello") z; // error: `#Hello` is not a recognized
mangling of a type
---
Earlier work: https://github.com/dlang/dmd/pull/11797
--
More information about the Digitalmars-d-bugs
mailing list