www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12632] New: Out of range indexing for std.typecons.Tuple

https://issues.dlang.org/show_bug.cgi?id=12632

          Issue ID: 12632
           Summary: Out of range indexing for std.typecons.Tuple emits a
                    bad diagnostic
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
import std.typecons;
import std.typetuple;

void main()
{
    {
    auto tup = TypeTuple!(1);
    auto a = tup[0];  // ok
    auto b = tup[1];  // Error: array index [1] is outside array bounds [0 ..
1]
    }

    {
    auto tup = tuple(1);
    auto a = tup[0];  // ok
    auto b = tup[1];  // Error: no [] operator overload for type Tuple!int
    }
}
-----

The second diagnostic is not informative.

--
Apr 24 2014