Bug 16387 – getSymbolsByUDA works with structs but fails with classes

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-08-14T10:08:00Z
Last change time
2016-10-01T11:47:10Z
Assigned to
gruen_tobias
Creator
o

Comments

Comment #0 by o — 2016-08-14T10:08:32Z
Here's an example: import std.stdio, std.traits; enum Attr; void main() { struct MyStruct { @Attr uint id; } class MyClass { @Attr uint id; } pragma(msg, getSymbolsByUDA!(MyStruct, Attr).stringof); // outputs: tuple(id) pragma(msg, getSymbolsByUDA!(MyClass, Attr).stringof); // error }
Comment #1 by gruen_tobias — 2016-08-15T20:47:17Z
Somehow related to Issue 14740. The problem is that MyClass is inside a function, and therefore will get a additional "this" member. The "this" member is inaccsessible, so if the library tries to search attribtues it will fail at this "this" member.
Comment #2 by github-bugzilla — 2016-08-30T11:13:35Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/b44e3bd24ad19836447bec5891e454958e288836 Fixed Issue 16387 (getSymbolsByUDA works with structs but fails with classes) - added a filter to skip the inaccessable 'this' member https://github.com/dlang/phobos/commit/ca5f5cdd13002e520c4474d43ec460457816fc24 Merge pull request #4752 from togrue/fix_16387 Fixed Issue 16387 - getSymbolsByUDA works with structs but fails with classes
Comment #3 by github-bugzilla — 2016-10-01T11:47:10Z