Bug 24567 – In interpolation token strings: "$(expression)" is not treated as interpolation expression

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2024-05-25T15:41:43Z
Last change time
2024-12-13T19:35:24Z
Assigned to
No Owner
Creator
Robert Luger
Moved to GitHub: dmd#20458 →

Comments

Comment #0 by robert.luger — 2024-05-25T15:41:43Z
The following is supposed to fill the members of `test` with the content of `assocarray`: import std; void main(){ struct Test { int a; } Test test; auto assocarray = [ "a": 1 ]; static foreach(member; __traits(allMembers, Test)) { mixin(iq{ writeln("$(member)"); test.$(member) = assocarray.get("$(member)", -1); }.text); } writeln(test.a); assert(test.a == 1); } Output: $(member) -1 core.exception.AssertError@.\test_token_interpolation.d(22): Assertion failure It looks like token strings are "tokenized" before interpolation and not after, which results in "string" tokens being completely ignored for interpolation.
Comment #1 by robert.schadek — 2024-12-13T19:35:24Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20458 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB