Bug 9575 – __traits(compiles, mixin()) incorrectly returns false

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-02-22T13:44:00Z
Last change time
2013-02-22T14:04:03Z
Assigned to
nobody
Creator
callumenator

Comments

Comment #0 by callumenator — 2013-02-22T13:44:47Z
DMD 2.062 void main() { enum test = "auto v = new int;"; pragma(msg, __traits(compiles, mixin(test))); // 'false' mixin(test); // compiles } A workaround is to wrap the test code in braces: enum test = "{auto v = new int;}"; // __traits(compiles) == true
Comment #1 by andrej.mitrovich — 2013-02-22T14:04:03Z
See the traits documentation: http://dlang.org/traits.html#compiles "The arguments cannot be statements or declarations."