Is this a bug in std.typecons.Tuple.slice?
Saurabh Das via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Feb 4 04:28:39 PST 2016
This code:
void main()
{
import std.typecons;
auto tp = tuple!("a", "b", "c")(10, false, "hello");
auto u0 = tp.slice!(0, tp.length);
auto u1 = tp.slice!(1, tp.length);
auto u2 = tp.slice!(2, tp.length);
static assert(is(typeof(u0) == Tuple!(int, "a", bool, "b",
string, "c")));
static assert(is(typeof(u1) == Tuple!(bool, "b", string,
"c")));
static assert(is(typeof(u2) == Tuple!(string, "c")));
assert(u2.c == "hello");
assert(u0.c == "hello");
assert(u1.c == "hello"); // This assert fails. Why?
}
core.exception.AssertError at erasetype.d(16): Assertion failure
----------------
4 erasetype 0x0000000100ce8128
_d_assert + 104
5 erasetype 0x0000000100cd12fe void
erasetype.__assert(int) + 38
6 erasetype 0x0000000100cd12aa _Dmain
+ 250
7 erasetype 0x0000000100cf7297
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv + 39
8 erasetype 0x0000000100cf71cf void
rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate()) + 55
9 erasetype 0x0000000100cf723c void
rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).runAll() + 44
10 erasetype 0x0000000100cf71cf void
rt.dmain2._d_run_main(int, char**, extern (C) int
function(char[][])*).tryExec(scope void delegate()) + 55
11 erasetype 0x0000000100cf7121
_d_run_main + 497
12 erasetype 0x0000000100cd133f main +
15
13 libdyld.dylib 0x00007fff8a1345c8 start
+ 0
14 ??? 0x0000000000000000 0x0 + 0
Why does 'u1' behave differently? I'm thinking it's a bug, but I
haven't worked much with tuples, so maybe I'm missing something?
Thanks,
Saurabh
More information about the Digitalmars-d-learn
mailing list