www.digitalmars.com         C & C++   DMDScript  

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


          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:
        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