www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4727] New: Passing std.concurrency.receive() a function of type Variant causes a static assert

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4727

           Summary: Passing std.concurrency.receive() a function of type
                    Variant causes a static assert
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Mac OS X
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: itsallaboutthedyo gmail.com


--- Comment #0 from Tim Keating <itsallaboutthedyo gmail.com> 2010-08-25
21:00:53 PDT ---
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".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4727



--- Comment #1 from Tim Keating <itsallaboutthedyo gmail.com> 2010-08-25
21:02:49 PDT ---
Shoot, that's what i < T.length does. Hmm, not sure why this is blowing up,
then.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4727



--- Comment #2 from Tim Keating <itsallaboutthedyo gmail.com> 2010-08-25
21:20:31 PDT ---
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 )

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4727



--- Comment #3 from Tim Keating <itsallaboutthedyo gmail.com> 2010-08-25
21:36:31 PDT ---
... 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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 25 2010
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4727


klickverbot <code klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |code klickverbot.at
         Resolution|                            |FIXED


--- Comment #4 from klickverbot <code klickverbot.at> 2011-12-10 13:16:41 PST
---
Fixed in commit b78bc4c59d8d9c87f55659baf277fce4960de7db resp. since 2.053.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 10 2011