Bug 1073 – CTFE: mixin expression with a function argument doesn't work

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-03-20T02:57:00Z
Last change time
2014-02-16T15:22:34Z
Assigned to
bugzilla
Creator
torhu

Comments

Comment #0 by torhu — 2007-03-20T02:57:38Z
This code checks if TEST is defined, and defines it if not. If using the line that's commented out instead of the one above it, it works as expected. --- const int TEST = 1; char[] def(char[] s) { if (!is(typeof(mixin(s)))) // doesn't detect that TEST is defined //if (!is(typeof(mixin("TEST")))) // this works fine return "const int " ~ s ~ " = 3;\n"; else return ""; } mixin(def("TEST")); void main() { } --- test.d: variable test.TEST conflicts with test.TEST at test.d(1) I tried to recreate this problem without CTFE, just with a static if, but it doesn't happen then.
Comment #1 by bugzilla — 2007-03-31T17:29:05Z
What this code is trying to do is to dynamically change the parse, rather than the evaluated result, at compile time. This isn't going to work (should use templates for that). I'll put some clarifications in the spec about this.