Bug 10004 – tuple comparison with side-effect should work
Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-04-28T19:57:00Z
Last change time
2013-05-10T17:35:54Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2013-04-28T19:57:30Z
By fixing issue 9873, built-in tuple comparison would be allowed from 2.063.
So this code should work, but doesn't.
extern(C) int printf(const char*, ...);
struct SZ(T...) { T field; alias field this; }
S make(S)() {
printf("make\n"); // necessary to make this function impure
S s;
return s;
}
void main()
{
struct SX(T...) { T field; alias field this; }
alias S = SX!(int, long);
assert(make!S.field == make!S.field); // tuple comparison
}
Output:
test.d(14): Error: expression ref SX!(int, long) __tup5 = make();
, (ref SX!(int, long) __tup6 = make();
) of type void does not have a boolean value