[Issue 20614] New: CTFE supports typid(stuff).name but not classinfo.name
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Feb 26 14:29:13 UTC 2020
https://issues.dlang.org/show_bug.cgi?id=20614
Issue ID: 20614
Summary: CTFE supports typid(stuff).name but not classinfo.name
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: CTFE
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: b2.temp at gmx.com
This commit https://github.com/dlang/dmd/pull/10796, adds support for
retireving the dynamic class name at compile time. but it only works with
typeid and not classinfo, which should be supported too since therey are the
same thing.
---
string classname(Object o)
{
return typeid(o).name;
}
string classnameAlt(Object o)
{
return o.classinfo.name;
}
class Panzer {}
class Tiger : Panzer {}
static assert (() {
Panzer p = new Tiger(); return classname(p);
} () == "Tiger"); // OK
static assert (() {
Panzer p = new Tiger(); return classnameAlt(p);
} () == "Tiger"); // NG
---
--
More information about the Digitalmars-d-bugs
mailing list