Bug 23570 – UDAs do not carry over in foreach over tupleof

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-12-20T11:12:59Z
Last change time
2024-12-13T19:26:26Z
Assigned to
No Owner
Creator
JR
Moved to GitHub: dmd#20206 →

Comments

Comment #0 by zorael — 2022-12-20T11:12:59Z
Manjaro/Arch x86_64, dmd 2.101.0 --- import std; enum UDA; struct Foo { @UDA int i; } void main() { Foo f; foreach (i, ref symbol; f.tupleof) { static assert(hasUDA!(symbol, UDA)); // fails static assert(hasUDA!(f.tupleof[i], UDA)); // succeeds } } --- I understand that it currently doesn't, but shouldn't it?
Comment #1 by razvan.nitu1305 — 2022-12-20T13:15:33Z
I don't think this can be "fixed". The problem is that the foreach is technically a runtime construct, therefore, the compiler sees `i` and `symbol` as runtime variables. I'm not sure if this can be fixed, looking into it.
Comment #2 by robert.schadek — 2024-12-13T19:26:26Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20206 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB