May 25 [Issue 24567] New: In interpolation token strings: "$(expression)" is not treated as interpolation expression | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24567 Issue ID: 24567 Summary: In interpolation token strings: "$(expression)" is not treated as interpolation expression Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: weltensturm@gmail.com 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. -- |
Copyright © 1999-2021 by the D Language Foundation