[Issue 12632] Out of range indexing for tuple subtype emits a bad diagnostic

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Apr 24 05:33:34 PDT 2014


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

Andrej Mitrovic <andrej.mitrovich at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Phobos                      |DMD
            Summary|Out of range indexing for   |Out of range indexing for
                   |std.typecons.Tuple emits a  |tuple subtype emits a bad
                   |bad diagnostic              |diagnostic

--- Comment #1 from Andrej Mitrovic <andrej.mitrovich at gmail.com> ---
Changing to a compiler bug:

-----
struct Tuple(T...)
{
    T t;
    alias t this;
}

auto tuple(T...)(T t)
{
    return Tuple!T(t);
}

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

--


More information about the Digitalmars-d-bugs mailing list