www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13846] New: Tuple behavior incorrect


          Issue ID: 13846
           Summary: Tuple behavior incorrect
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: phil.burr gmail.com

DMD32 D Compiler v2.066.0
Copyright (c) 1999-2014 by Digital Mars written by Walter Bright
Documentation: http://dlang.org/

I'm not sure entirely how to describe the bug, other than with code. I've
reduced the bug to the following:

import std.typecons;

struct Bar
    Tuple!(string, Bar) bar[];

struct Foo
    Tuple!(string, Bar) bar[];

void main()
    auto t0 = tuple("test", Foo());
    auto t1 = tuple("test", Bar());
    assert(t0[0] == "test");    
    assert(t1[0] == "test");    

The first assertion (t0[0] == "test") succeeds whereas the second assertion
(t1[0] == "test") fails.  The difference between the two is that Bar contains a
tuple that references itself where as Foo contains a tuple that references a
different type.

C:\>rdmd test.d
core.exception.AssertError test.d(18): Assertion failure
0x7607919F in BaseThreadInitThunk
0x76FB0BBB in RtlInitializeExceptionChain
0x76FB0B91 in RtlInitializeExceptionChain

Dec 09 2014