August 15, 2022 [Issue 4576] [tdpl] 0/1 argument calls to overloaded function is allowed in presence of variadic function | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=4576 RazvanN <razvan.nitu1305@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |razvan.nitu1305@gmail.com Resolution|--- |INVALID --- Comment #5 from RazvanN <razvan.nitu1305@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 -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply