From b60f504bd52e67457c3b56f5e39f61b494d3f86b Mon Sep 17 00:00:00 2001 From: usefahmed07 Date: Thu, 10 Sep 2026 00:52:52 +0300 Subject: [PATCH] Fix Issue 21294 - Improve unhelpful error message with duplicate named argument in overload set Named-argument errors (e.g. "parameter assigned twice") were only reported via checkNamedArgErrorAndReportOverload() when the symbol was an OverDeclaration (od). Plain function overloads declared in the same scope use the fd.overnext chain instead, so the hasOverloads branch in resolveFuncCall() never ran this check and fell back to the generic "none of the overloads are callable" message. Call checkNamedArgErrorAndReportOverload(fd, ...) in that branch too, since overloadApply() already supports walking fd.overnext. --- compiler/src/dmd/funcsem.d | 1 + compiler/test/fail_compilation/issue21294.d | 22 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 compiler/test/fail_compilation/issue21294.d diff --git a/compiler/src/dmd/funcsem.d b/compiler/src/dmd/funcsem.d index 2f3927abff11..a8fb8b5bc6f4 100644 --- a/compiler/src/dmd/funcsem.d +++ b/compiler/src/dmd/funcsem.d @@ -2177,6 +2177,7 @@ FuncDeclaration resolveFuncCall(Loc loc, Scope* sc, Dsymbol s, { eSink.error(loc, "none of the overloads of `%s` are callable using argument types `%s`", fd.toErrMsg(), fargsBuf.peekChars()); + checkNamedArgErrorAndReportOverload(fd, argumentList, loc); printCandidates(loc, fd, sc.isDeprecated()); return null; } diff --git a/compiler/test/fail_compilation/issue21294.d b/compiler/test/fail_compilation/issue21294.d new file mode 100644 index 000000000000..ee87776a146d --- /dev/null +++ b/compiler/test/fail_compilation/issue21294.d @@ -0,0 +1,22 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/issue21294.d(18): Error: none of the overloads of `fun` are callable using argument types `(int, int)` +fail_compilation/issue21294.d(18): parameter `a` assigned twice +fail_compilation/issue21294.d(13): Candidates are: `issue21294.fun(int a)` +fail_compilation/issue21294.d(14): `issue21294.fun(int a, int b)` +--- +*/ + +// https://github.com/dlang/dmd/issues/21294 + +void fun(int a) {} +void fun(int a, int b) {} + +void main() +{ + fun( + a: 2, + a: 4, + ); +}