www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19399] New: Different Conversion Rules for Same Value and

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

          Issue ID: 19399
           Summary: Different Conversion Rules for Same Value and Type --
                    Enum
           Product: D
           Version: D2
          Hardware: Other
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: sprink.noreply gmail.com

void foo(byte v) { writeln("byte ", v); }
void foo(int v) { writeln("int ", v); }

enum A : int {
    a = 127,
    b = 128, // shh just ignore this
}

void main()
{
    A v = A.a;
    foo(A.a);  // byte 127
    foo(v);    // int 127 should be byte 127
}


Per https://issues.dlang.org/show_bug.cgi?id=10560 the desired type to call is
"byte".  So the bug should be fixed so that both the function call the
foo(byte) overload.

--
Nov 13 2018