www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20850] New: Can't assign enum of Tuple

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

          Issue ID: 20850
           Summary: Can't assign enum of Tuple
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

import std.typecons : Tuple, tuple;

enum RC5Command: Tuple!(ubyte, ubyte) {
       Standby = RC5Command(0,0)
}

unittest {
    RC5Command rc5command = RC5Command.Standby;
    rc5command = RC5Command.Standby; // This line
}

The above code fails to compile with:

Error: template std.typecons.Tuple!(ubyte, ubyte).Tuple.opAssign cannot deduce
function from argument types !()(RC5Command), candidates are:
/usr/lib/ldc/x86_64-linux-gnu/include/d/std/typecons.d(900,19):
        opAssign(R)(auto ref R rhs)
  with R = RC5Command
  must satisfy the following constraint:
       areCompatibleTuples!(typeof(this), R, "=")

The root cause of this is areCompatibleTuples checks isTuple!Tup2, and should
check isTuple!(OriginalType!Tup2) to account for enums.

--
May 20 2020