I just noticed that ClassInfo.find doesn't work for nested classes, even if they are static. For example:
unittest
{
static class Foo { }
auto name = Foo.classinfo.name;
assert(ClassInfo.find(name) is null); // unfortunately passes
}
I was about to try the documented unit test feature in my work on std.serialization but I want to have the type I'm serializing visible in the example as well.
Is it possible to fix somehow? I looked at the symbol table and it seems the class info is there, but ClassInfo.find just can't find it.
0000000100040980 D _D4test14__unittestL7_1FZv3Foo6__initZ
0000000100040a50 D _D4test14__unittestL7_1FZv3Foo6__vtblZ
00000001000409b0 D _D4test14__unittestL7_1FZv3Foo7__ClassZ
Comment #1 by yebblies — 2013-11-20T07:50:26Z
This is almost certainly a druntime bug
Comment #2 by doob — 2013-11-20T13:09:18Z
I'm pretty sure that class infos for nested classes are never added by the compiler in the first place, see this:
https://github.com/D-Programming-Language/dmd/blob/master/src/toobj.c#L68-L73
The compiler needs to iterate all types that can have nested classes, not just the members of the module, as it does now. I tried to fix this myself but I haven't been able to figure out how to iterate all nested types of a function.
I'm setting this back to an issue with the compiler.
Comment #3 by doob — 2013-11-20T13:11:30Z
I would say that "addLocalClass" should be implemented by all Dsymbols that have members.
Comment #4 by robert.schadek — 2024-12-13T18:10:40Z