[Issue 144] Alias and function names fail to collide

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 1 15:47:29 UTC 2017


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

RazvanN <razvan.nitu1305 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |razvan.nitu1305 at gmail.com
         Resolution|---                         |INVALID

--- Comment #4 from RazvanN <razvan.nitu1305 at gmail.com> ---
This is not a bug, it's the desired behavior since alias is used to include
functions in the same overload set. It can't issue an error when an alias has
the same name as a function, otherwise it would be impossible to bring other
functions to the overload set.

For example: if you have 3 foo overloads:

void foo() {}
void foo(int a) {}
void foo(int a, int b) {}

and you want to bring an imported function in the same overload set you do:

alias foo = path.to.import.foo

The problem in your example is that the 2 functions you bring in the same
overload set have the exact same signature and are in the same file. So the
compiler let's alias your function because it thinks you want to have the in
the same overload set, but when you try to call it, it issues an error because
it does not know which one it should call. This is correct behavior.

Closing as invalid.

--


More information about the Digitalmars-d-bugs mailing list