[Issue 4576] [tdpl] 0/1 argument calls to overloaded function is allowed in presence of variadic function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Aug 15 12:20:28 UTC 2022


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

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

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

--- Comment #5 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to Andrej Mitrovic from comment #4)
> Reduced test-case:
> 
> -----
> void test(int[] arr...) { assert(1); }
> void test() { assert(0); }  // hijacks (shadows) above function
> 
> void main()
> {
>     test();  // should fail at CT, not RT.
> }
> -----
> 
> Comment out the second function and the first one will be called. The
> `test()` call should be ambiguous and issue a compile-time error.

The compiler sees that both functions match, however, the non-variadic one is
more specialized and the variadic one. This is all described very well in the
spec [1]. More specifically, point 5 in the section that I linked.

Closing as invalid.

[1] https://dlang.org/spec/function.html#function-overloading

--


More information about the Digitalmars-d-bugs mailing list