Bug 10498 – `__traits(compiles, ...)` affect program behaviour

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-06-29T00:50:00Z
Last change time
2013-07-08T19:12:15Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2013-06-29T00:50:51Z
`{ T; }` delegate makes `static assert` fail: --- template triggerIssue() { enum triggerIssue = __traits(compiles, { T; }); } template PackedGenericTuple(Args...) { alias Args Tuple; enum e = triggerIssue!(); } struct S { } template T() { alias T = PackedGenericTuple!S; } void main() { alias t = T!(); static assert(is(t.Tuple[0])); // Fails } ---
Comment #1 by verylonglogin.reg — 2013-06-29T00:56:14Z
Another situation: --- template triggerIssue(A...) { enum triggerIssue = __traits(compiles, { auto a = A[0]; }); } template PackedGenericTuple(Args...) { alias Args Tuple; enum e = triggerIssue!Args; } template T() { struct S{} // The fact `S` is in `T` causes the problem alias T = PackedGenericTuple!S; } void main() { alias t = T!(); static assert(is(t.Tuple[0])); } --- The second one is reduced (no sure if correct) from regression failure.
Comment #2 by k.hara.pg — 2013-06-30T02:30:16Z
Compiler fix for the first case. https://github.com/D-Programming-Language/dmd/pull/2280 I'm not sure the second case is really a regression. If not, it should be filed as a separate issue.
Comment #3 by k.hara.pg — 2013-06-30T03:28:36Z
(In reply to comment #2) > Compiler fix for the first case. > https://github.com/D-Programming-Language/dmd/pull/2280 > > I'm not sure the second case is really a regression. If not, it should be filed > as a separate issue. OK, indeed the second case would have the same root cause with the first. I updated the PR to fix the both cases.
Comment #4 by github-bugzilla — 2013-07-08T03:54:15Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/abbbbc419d0c792a04f715fcd8c60831764dc294 fix Issue 10498 - `__traits(compiles, ...)` affect program behaviour https://github.com/D-Programming-Language/dmd/commit/6c6765783609e06ef9634f16f6d6a2035da8ec8f Merge pull request #2280 from 9rnsr/fix10498 [REG2.061] Issue 10498 - `__traits(compiles, ...)` affect program behaviour