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.
(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