Bug 22696 – getSymbolsByUDA can't be used in static foreach over parent type

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-01-22T02:22:43Z
Last change time
2024-12-01T16:39:54Z
Assigned to
No Owner
Creator
Jack Stouffer
Moved to GitHub: phobos#10489 →

Comments

Comment #0 by jack — 2022-01-22T02:22:43Z
Here is a simplified version of real code I tried to write using getSymbolsByUDA: import std.traits; enum Runnable; struct SubSystem { void run(); } struct Manager { @Runnable SubSystem subsystem; void run() { static foreach(system; getSymbolsByUDA!(Manager, Runnable)) { system.run(); } } } void main() { Manager m; m.run(); } Result: onlineapp.d(16): Error: value of `this` is not known at compile time This seems to be the most logical and straight-forward way to write this code. Whether it's due to a bug in the getSymbolsByUDA implementation, a bug in DMD, or a limitation in the language, it's my personal opinion this code should compile and "just work". At the VERY LEAST the error message should be more helpful to the user on how to get the desired functionality.
Comment #1 by robert.schadek — 2024-12-01T16:39:54Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10489 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB