Bug 20586 – Ambiguous overload set with default parameter gives confusing error message

Status
NEW
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-02-19T09:12:42Z
Last change time
2024-12-13T19:07:08Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Mathias LANG
Moved to GitHub: dmd#17939 →

Comments

Comment #0 by pro.mathias.lang — 2020-02-19T09:12:42Z
The following code: ``` void main () nothrow { foo("hello"); } void foo (string) @system nothrow {} void foo (string) @safe { } ``` Results in the following error message: ``` test.d(3): Error: test.foo called with argument types (string) matches both: test.d(6): test.foo(string) and: test.d(7): test.foo(string) ``` But when changing the definition of `foo` to: ``` void foo (string, float f = 42) @system nothrow {} void foo (string, int a = 42) @safe { } ``` We get: ``` test.d(6): Error: function nope.foo is not nothrow test.d(1): Error: nothrow function D main may throw ``` Which, if a user expect overloading to work with different attributes, is confusing.
Comment #1 by robert.schadek — 2024-12-13T19:07:08Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17939 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB