www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17631] New: can overlaod functions with simple enum argument,

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

          Issue ID: 17631
           Summary: can overlaod functions with simple enum argument, but
                    not with complex enum argument
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: eric makechip.com

import std.stdio;

enum A : int { a, b };
enum B : int { a, b };
enum AS : string[2] { a = ["1","2"], b = ["3","4"] };
enum BS : string[2] { a = ["5","6"], b = ["7","8"] };

void func(A x)   { writeln("A");  }
void func(B x)   { writeln("B");  }
void funcs(AS x) { writeln("AS"); }
void funcs(BS x) { writeln("BS"); }

void test()
{
    func(A.a); // no compiler error
    funcs(AS.a); // compiler error: matches both funcs(AS) and funcs(BS)
}

void main(string[] args) { }

In the above code, the functions with the simple enum type argument can
be overloaded, but the functions with the complex enum type argument cannot be
overloaded.

--
Jul 10 2017