Bug 9650 – __traits(compiles) + mixin

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-03-05T08:52:00Z
Last change time
2015-06-09T05:12:00Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
callumenator

Comments

Comment #0 by callumenator — 2013-03-05T08:52:27Z
DMD2.062: http://forum.dlang.org/thread/[email protected]#post-tdojcnsrtkygjbhwegph:40forum.dlang.org import std.conv; void main() { enum s = "`1`.to!int;"; enum c = __traits(compiles, mixin("{auto a = new "~s~";}")); // line 1 mixin("auto a = "~s~";"); // line 2 } Long errors about instantiating std.conv.to!(int).to!(string). Swap lines 1 and 2 and compilation succeeds. This worked in 2.061. Possibly related to issue 9017.
Comment #1 by k.hara.pg — 2013-03-08T02:02:27Z
Comment #2 by github-bugzilla — 2013-03-23T12:19:57Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/ac89791f2a4c54cb255ee7e802fde74643b12412 fix Issue 9650 - __traits(compiles) + mixin I couldn't minimize test case, but the bug fix is obvious. The bug had been hiding for a long time, but recent Phobos change (https://github.com/D-Programming-Language/phobos/commit/2a88fea7867f33fd1cf15c2dca7790a3c8aea474) had exposed the bug. When a mixin expression gets invalid code string, the parsing error had not handled correctly. In such case, it had generated *invalid* AST instead of returning ErrorExp. I guess that the invalid AST would report weird error in later semantic analysis. I think that both CompileDeclaration and CompileStatement do not have same problem. So they are not changed. https://github.com/D-Programming-Language/dmd/commit/618d8277aaf20c9f8d8eebc39289e3d2a1c63d42 Merge pull request #1728 from 9rnsr/fix9650 Issue 9650 - __traits(compiles) + mixin
Comment #3 by github-bugzilla — 2013-03-23T12:22:13Z
Commit pushed to dmd-1.x at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/a4de3b4e56fd70e0982eed2a55abdc6df20d18db Merge pull request #1728 from 9rnsr/fix9650 Issue 9650 - __traits(compiles) + mixin
Comment #4 by github-bugzilla — 2013-03-23T12:26:02Z
Commit pushed to 2.062 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/f62c899fecf3ab58e9d20d1b413bfb06f0d26a95 Merge pull request #1728 from 9rnsr/fix9650 Issue 9650 - __traits(compiles) + mixin