Bug 1083 – classtype.classinfo.name can't be evaluated in compile-time
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-03-27T23:30:00Z
Last change time
2014-02-16T15:23:06Z
Assigned to
bugzilla
Creator
davidl
Comments
Comment #0 by davidl — 2007-03-27T23:30:17Z
template typeadder(T)
{
const char[] typeadder=T.classinfo.name~"hello";
}
class classa
{
}
void main()
{
pragma(msg,typeadder!(classa));
}
above should compile
and following throws me insane error message
class MyClass
{
}
class MyClassInLine
{
}
template classcast(T)
{
const char[] inlinename=T.classinfo.name~"InLine";
char[] classcastfunc(T.classinfo.name)
{
auto ktype= addinline(T.classinfo.name);
return
inlinename~" classcast("~T.classinfo.name~" base)
{
"~inlinename~" ret;
ret = cast("~inlinename~")cast(void*)base;
ret.classinfo.vtbl="~inlinename~".classinfo.vtbl;
return ret;
}"
;
}
mixin(classcastfunc(T.name));
}
void main()
{
MyClass a= new MyClass;
MyClassInLine v;
v.classinfo.vtbl = MyClass.classinfo.vtbl;
v= classcast!(MyClass)(a);
}
error message:
testclassinfo.d(13): Error: no property 'classinfo' for type 'testclassinfo.MyClass'
Yet MyClass should has the property classinfo
Comment #1 by bugzilla — 2007-03-30T15:32:06Z
Please put different bugs in separate bug reports.
Comment #2 by davidl — 2007-09-15T21:59:58Z
i can use stringof to bypass this kind of request. So this should be invalid.
cause ClassInfo is a runtime info though which might looks like compile time determined.