[Issue 17983] Integer literal should prefer int to char overload

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 15 14:37:01 UTC 2017


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

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m

--- Comment #4 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
I just updated to the latest HEAD, and I get the error. However, this really
has nothing to do with overloading. This code

auto foo(char c) { return 1; };
auto foo(int i) { return 4; };

enum int e = 7;
static assert(foo(e) == 4); // fails

compiles just fine. The problem is that you have two aliases, and only one
wins. All you have to do is flip the order of declaration of the aliases, and
there is no error.

Either declaring two aliases with the same name should result in an error
(which it does when you're not aliasing lambdas), or the aliases need to be
treated as actual function overloads. Personally, I'm inclined to argue that it
should just be an error and that if someone wants to do overloading, they
should just declare actual functions rather than using an alias.

--


More information about the Digitalmars-d-bugs mailing list