Bug 4727 – Passing std.concurrency.receive() a function of type Variant causes a static assert

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Mac OS X
Creation time
2010-08-25T21:00:00Z
Last change time
2011-12-10T13:16:41Z
Assigned to
nobody
Creator
itsallaboutthedyo

Comments

Comment #0 by itsallaboutthedyo — 2010-08-25T21:00:53Z
Example 13.6.2 from The D Programming Language (p. 405; trivial example of using a function that takes a single Variant type as a "catch all" message handler) does not compile for me. This is using DMD 2.048 and Phobos dated 8/10/10. The compile error occurs in the static assert on line 385 of concurrency.d. As far as I can tell, the assert says "if we have only one param, and it's a variant, die." Seems to me it needs an additional clause, "... and this isn't the last element in the T array".
Comment #1 by itsallaboutthedyo — 2010-08-25T21:02:49Z
Shoot, that's what i < T.length does. Hmm, not sure why this is blowing up, then.
Comment #2 by itsallaboutthedyo — 2010-08-25T21:20:31Z
Ah, it's an off-by-one error. The index is 0-based, but T.length is 1-based. That expression should be: if ( i < T.length-1 )
Comment #3 by itsallaboutthedyo — 2010-08-25T21:36:31Z
... and that if might want to be a static if also. I'm not sure why straight "if" wasn't working for me, but it was not successfully evaluating the comparison, so it would still get into the inner block when i == T.length-1 (confirmed by doing a static assert (i != T.length-1), which failed). Changing that to a static if seemed to make it work, however.
Comment #4 by code — 2011-12-10T13:16:41Z
Fixed in commit b78bc4c59d8d9c87f55659baf277fce4960de7db resp. since 2.053.