D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4727 - Passing std.concurrency.receive() a function of type Variant causes a static assert
Summary: Passing std.concurrency.receive() a function of type Variant causes a static ...
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86 Mac OS X
: P2 major
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-25 21:00 UTC by Tim Keating
Modified: 2011-12-10 13:16 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Tim Keating 2010-08-25 21:00:53 UTC
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 Tim Keating 2010-08-25 21:02:49 UTC
Shoot, that's what i < T.length does. Hmm, not sure why this is blowing up, then.
Comment 2 Tim Keating 2010-08-25 21:20:31 UTC
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 Tim Keating 2010-08-25 21:36:31 UTC
... 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 David Nadlinger 2011-12-10 13:16:41 UTC
Fixed in commit b78bc4c59d8d9c87f55659baf277fce4960de7db resp. since 2.053.