Thread overview
[Issue 4406] New: Typo (bug) in std.concurrency
Jun 29, 2010
Simen Kjaeraas
Jun 29, 2010
Simen Kjaeraas
June 29, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4406

           Summary: Typo (bug) in std.concurrency
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: patch
          Severity: critical
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: simen.kjaras@gmail.com


--- Comment #0 from Simen Kjaeraas <simen.kjaras@gmail.com> 2010-06-29 06:57:01 PDT ---
Line 609 of trunk std.concurrency contains a typo that makes it not compile:

        final void get(T...)( T ops )
        {
            static assert( T.length );

            static if( isImplicitlyConvertible!(T[0], long) )
            {
                alias TypeTuple!(T[1 .. $]) Ops;
                enum timedWait = true;
                assert( ops[0] >= 0 );
                long period = ops[0];
                ops = ops[1 .. $];  // Line 609
            }

Lines 609 should instead be:
                Ops = ops[1 .. $];
(note capitalization)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 29, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4406



--- Comment #1 from Steven Schveighoffer <schveiguy@yahoo.com> 2010-06-29 07:40:36 PDT ---
Ops is a type, I don't think that will compile.

I'd say a more complex solution is needed:

        final void get(T...)( T _ops )
        {
            static assert( T.length );

            static if( isImplicitlyConvertible!(T[0], long) )
            {
                alias TypeTuple!(T[1 .. $]) Ops;
                enum timedWait = true;
                assert( _ops[0] >= 0 );
                long period = _ops[0];
                Ops ops = _ops[1 .. $];  // Line 609
            }
            else
            {
                 alias TypeTuple!(T) Ops;
                 enum timedWait = false;
                 alias _ops ops; // not sure if this works
            }

If the alias doesn't work, you may have to do something with the function signature.  I'm not sure how assigning _ops to ops will work, it may invoke some unnecessary ctors/dtors.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 29, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4406



--- Comment #2 from Simen Kjaeraas <simen.kjaras@gmail.com> 2010-06-29 07:53:41 PDT ---
(In reply to comment #1)
> Ops is a type, I don't think that will compile.
> 
> I'd say a more complex solution is needed:
> 
>         final void get(T...)( T _ops )
>         {
>             static assert( T.length );
> 
>             static if( isImplicitlyConvertible!(T[0], long) )
>             {
>                 alias TypeTuple!(T[1 .. $]) Ops;
>                 enum timedWait = true;
>                 assert( _ops[0] >= 0 );
>                 long period = _ops[0];
>                 Ops ops = _ops[1 .. $];  // Line 609
>             }
>             else
>             {
>                  alias TypeTuple!(T) Ops;
>                  enum timedWait = false;
>                  alias _ops ops; // not sure if this works
>             }
> 
> If the alias doesn't work, you may have to do something with the function signature.  I'm not sure how assigning _ops to ops will work, it may invoke some unnecessary ctors/dtors.

I don't think it's necessary to to assign anything the way you do. All that's needed is renaming the ops argument to _ops, and adding an alias in both clauses of the static if:

        final void get(T...)( T _ops )
        {
            static assert( T.length );

            static if( isImplicitlyConvertible!(T[0], long) )
            {
                alias TypeTuple!(T[1 .. $]) Ops;
                enum timedWait = true;
                assert( ops[0] >= 0 );
                long period = ops[0];
                alias _ops[1 .. $] ops; // Here
            }
            else
            {
                alias TypeTuple!(T) Ops;
                enum timedWait = false;
                alias _ops ops; // And here
            }

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 13, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4406


Lars T. Kyllingstad <bugzilla@kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@kyllingen.net
         Resolution|                            |FIXED


--- Comment #3 from Lars T. Kyllingstad <bugzilla@kyllingen.net> 2010-08-13 02:00:58 PDT ---
Fixed DMD 2.048.

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