www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4441] New: TDPL Example on P401 & 402 doesn't compile on D2.047, 2.046, 2.045, 2.044. Seems to be a problem involves tuples and []

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

           Summary: TDPL Example on P401 & 402 doesn't compile on D2.047,
                    2.046, 2.045, 2.044. Seems to be a problem involves
                    tuples and []
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: gareth.tpc gmail.com



The example:

import std.concurrency, std.stdio, std.contracts; /*std.contracts was missing
in the book, but this is fairly trivial change*/

void main() {
    auto low = 0, high = 100;
    auto tid = spawn(&writer);
    foreach(i; low .. high) {
        writeln("Main thread: ",i);
        tid.send(thisTid,i);
        enforce(receiveOnly!Tid() == tid);
    }
}

void writer() {
    for(;;) {
        auto msg = receiveOnly!(Tid,int)();
        writeln("Secondary thread: ", msg[1]);  //Line 17
        msg[0].send(thisTid);                   //Line 18
    }
}

thread_test.d(17): Error: no [] operator overload for type Tuple!(Tid,int)
thread_test.d(18): Error: no [] operator overload for type Tuple!(Tid,int)


Trying to compile with version 2.044-2.046 produces these errors
thread_test.d(10): Error: template std.typecons.Tuple!(Tid).Tuple.opEquals(T)
if (is(typeof(T.field))) does not match any function template declaration
thread_test.d(10): Error: template std.typecons.Tuple!(Tid).Tuple.opEquals(T)
if (is(typeof(T.field))) cannot deduce template function from argument types
!()(Tid)

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




Possible minimal case:

import std.typecons;

void main() {
    Tuple!(int,int) x;
    int y=x[0];
}
thread_test.d(5): Error: no [] operator overload for type Tuple!(int,int)

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


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei metalanguage.com



18:55:20 PDT ---
This is one big reason for the introduction of alias this. However, there was
never time to fix it. I agree it's a major bug.

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


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |clugdbug yahoo.com.au
         Resolution|                            |FIXED



Fixed DMD2.050.

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