www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21335] New: Compiler implicitly converts array to int[] when

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

          Issue ID: 21335
           Summary: Compiler implicitly converts array to int[] when it
                    doesn't have to
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: andrej.mitrovich gmail.com

-----
enum OP : ubyte
{
    PUSH = 2
}

void take (ubyte[]) { }

void main ()
{
    ubyte[2] bytes;
    take([OP.PUSH, bytes[0]]);  // ok
    take([bytes[0]] ~ bytes);   // ok
    take([OP.PUSH, bytes[0]] ~ bytes);  // error. promotion to int[]?!
}
-----

Why is it promoting `OP.PUSH` into an integer in the last call? It makes
absolutely no sense at all.

--
Oct 20 2020