http://d.puremagic.com/issues/show_bug.cgi?id=6385

           Summary: isInputRange!(ubyte[2u]) is a failure when used in
                    global scope
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Keywords: rejects-valid
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: schvei...@yahoo.com


--- Comment #0 from Steven Schveighoffer <schvei...@yahoo.com> 2011-07-26 
11:18:02 PDT ---
The following code incorrectly produces an error:

import std.range;

pragma(msg, isInputRange!(ubyte[2u]).stringof);

Error: template instance std.array.front!(ubyte[2u]) incompatible arguments for
template instantiation

The code of isInputRange looks like this:

template isInputRange(R)
{
    enum bool isInputRange = is(typeof(
    {
        R r;              // can define a range object
        if (r.empty) {}   // can test for empty
        r.popFront();     // can invoke popFront()
        auto h = r.front; // can get the front of the range
    }()));
}

It was my impression that is(typeof(...)) should just return false on
compilation failure.  I don't think isInputRange is incorrectly implemented.

The error is eliminated if you put the isInputRange call inside a function:

import std.range;

void main() { 
pragma(msg, isInputRange!(ubyte[2u]).stringof);
}

outputs:

false

during compilation, and successfully compiles.

See related discussion here:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=28422

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

Reply via email to