D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 10853 - ClassInfo.find doesn't work for nested classes
Summary: ClassInfo.find doesn't work for nested classes
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-19 08:11 UTC by Jacob Carlborg
Modified: 2024-12-13 18:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jacob Carlborg 2013-08-19 08:11:38 UTC
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 yebblies 2013-11-20 07:50:26 UTC
This is almost certainly a druntime bug
Comment 2 Jacob Carlborg 2013-11-20 13:09:18 UTC
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 Jacob Carlborg 2013-11-20 13:11:30 UTC
I would say that "addLocalClass" should be implemented by all Dsymbols that have members.
Comment 4 dlangBugzillaToGithub 2024-12-13 18:10:40 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18654

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB