Bug 19292 – Mixin expressions should take an argument list the same as pragma(msg) does
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-10-08T03:08:12Z
Last change time
2021-04-02T05:45:23Z
Assigned to
No Owner
Creator
Walter Bright
Comments
Comment #0 by bugzilla — 2018-10-08T03:08:12Z
Mixin expressions are currently limited to being strings:
https://dlang.org/spec/expression.html#mixin_expressions
While they should accept what the more flexible pragma(msg) does:
https://dlang.org/spec/pragma.html#msg
This will make more complex mixin expressions easier to write without depending on Phobos for formatting, and will run faster and require less memory for CTFE to evaluate.
Comment #1 by bugzilla — 2018-10-08T03:10:03Z
Test case:
int test() {
return mixin("1", 2);
}
void testit() {
static assert(test() == 12);
}
I like it! Really pargma-tic and will optimize many uses of mixin.
Comment #10 by default_357-line — 2020-01-20T11:23:48Z
Why does this allow evaluating types as their stringof? That may be fine for a debug tool like pragma(msg, but it's horrible for a mixin because it does the very, very wrong thing. Ie. if you have a template with a parameter T instantiated with int, then if you decide to use it as a mixin argument, you'll get "int", not "T" - which is fine, but rapidly becomes not fine when it's a private type in another module.
Comment #11 by dlang-bot — 2021-04-02T05:45:23Z
dlang/dmd pull request #12339 "[dmd-cxx] Backport fixes and trivial features from upstream dmd" was merged into dmd-cxx:
- 4cf3e2c00b7f7d636f50290db49efe618698d5c2 by Walter Bright:
[dmd-cxx] fix Issue 19292 - Mixin expressions should take an argument list the same as pragma(msg) does
https://github.com/dlang/dmd/pull/12339