Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassInfo.find doesn't work for nested classes #18654

Open
dlangBugzillaToGithub opened this issue Aug 19, 2013 · 3 comments
Open

ClassInfo.find doesn't work for nested classes #18654

dlangBugzillaToGithub opened this issue Aug 19, 2013 · 3 comments

Comments

@dlangBugzillaToGithub
Copy link

Jacob Carlborg (@jacob-carlborg) reported this on 2013-08-19T08:11:38Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=10853

CC List

  • yebblies

Description

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
@dlangBugzillaToGithub
Copy link
Author

yebblies commented on 2013-11-20T07:50:26Z

This is almost certainly a druntime bug

@dlangBugzillaToGithub
Copy link
Author

doob (@jacob-carlborg) commented on 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.

@dlangBugzillaToGithub
Copy link
Author

doob (@jacob-carlborg) commented on 2013-11-20T13:11:30Z

I would say that "addLocalClass" should be implemented by all Dsymbols that have members.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant