mirror of
https://github.com/dlang/dmd.git
synced 2025-04-28 14:10:11 +03:00
Don't use 'Candidate is' when there is more than one alias function overload (#14618)
* Fix Issue 23459 - Don't use 'Candidate is' when there is more than one alias function overload
This commit is contained in:
parent
4731b401d7
commit
5e7e313a04
3 changed files with 16 additions and 6 deletions
|
@ -3357,7 +3357,20 @@ if (is(Decl == TemplateDeclaration) || is(Decl == FuncDeclaration))
|
||||||
|
|
||||||
// determine if the first candidate was printed
|
// determine if the first candidate was printed
|
||||||
bool printed = false;
|
bool printed = false;
|
||||||
|
int count;
|
||||||
|
overloadApply(declaration, (Dsymbol s)
|
||||||
|
{
|
||||||
|
if (auto fd = s.isFuncDeclaration())
|
||||||
|
{
|
||||||
|
if (fd.errors || fd.type.ty == Terror)
|
||||||
|
return 0;
|
||||||
|
if (fd.storage_class & STC.disable || (fd.isDeprecated() && !showDeprecated))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
return count > 1; // early exit
|
||||||
|
});
|
||||||
|
const single_candidate = count == 1;
|
||||||
overloadApply(declaration, (Dsymbol s)
|
overloadApply(declaration, (Dsymbol s)
|
||||||
{
|
{
|
||||||
Dsymbol nextOverload;
|
Dsymbol nextOverload;
|
||||||
|
@ -3373,7 +3386,6 @@ if (is(Decl == TemplateDeclaration) || is(Decl == FuncDeclaration))
|
||||||
if (fd.storage_class & STC.disable || (fd.isDeprecated() && !showDeprecated))
|
if (fd.storage_class & STC.disable || (fd.isDeprecated() && !showDeprecated))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
const single_candidate = fd.overnext is null;
|
|
||||||
auto tf = cast(TypeFunction) fd.type;
|
auto tf = cast(TypeFunction) fd.type;
|
||||||
.errorSupplemental(fd.loc,
|
.errorSupplemental(fd.loc,
|
||||||
printed ? " `%s%s`" :
|
printed ? " `%s%s`" :
|
||||||
|
@ -3390,8 +3402,6 @@ if (is(Decl == TemplateDeclaration) || is(Decl == FuncDeclaration))
|
||||||
const tmsg = td.toCharsNoConstraints();
|
const tmsg = td.toCharsNoConstraints();
|
||||||
const cmsg = td.getConstraintEvalError(constraintsTip);
|
const cmsg = td.getConstraintEvalError(constraintsTip);
|
||||||
|
|
||||||
const single_candidate = td.overnext is null;
|
|
||||||
|
|
||||||
// add blank space if there are multiple candidates
|
// add blank space if there are multiple candidates
|
||||||
// the length of the blank space is `strlen("Candidates are: ")`
|
// the length of the blank space is `strlen("Candidates are: ")`
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
TEST_OUTPUT:
|
TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
fail_compilation/diag14818.d(40): Error: none of the overloads of `func` are callable using argument types `(string)`
|
fail_compilation/diag14818.d(40): Error: none of the overloads of `func` are callable using argument types `(string)`
|
||||||
fail_compilation/diag14818.d(18): Candidate is: `diag14818.foo(int _param_0)`
|
fail_compilation/diag14818.d(18): Candidates are: `diag14818.foo(int _param_0)`
|
||||||
fail_compilation/diag14818.d(19): `diag14818.bar(double _param_0)`
|
fail_compilation/diag14818.d(19): `diag14818.bar(double _param_0)`
|
||||||
fail_compilation/diag14818.d(41): Error: template instance `diag14818.X!string` does not match any template declaration
|
fail_compilation/diag14818.d(41): Error: template instance `diag14818.X!string` does not match any template declaration
|
||||||
fail_compilation/diag14818.d(41): Candidates are:
|
fail_compilation/diag14818.d(41): Candidates are:
|
||||||
|
|
|
@ -3,7 +3,7 @@ TEST_OUTPUT:
|
||||||
---
|
---
|
||||||
fail_compilation/ice13459.d(12): Error: undefined identifier `B`
|
fail_compilation/ice13459.d(12): Error: undefined identifier `B`
|
||||||
fail_compilation/ice13459.d(18): Error: none of the overloads of `opSlice` are callable using argument types `(int, int)`
|
fail_compilation/ice13459.d(18): Error: none of the overloads of `opSlice` are callable using argument types `(int, int)`
|
||||||
fail_compilation/ice13459.d(11): Candidates are: `ice13459.A.opSlice()`
|
fail_compilation/ice13459.d(11): Candidate is: `ice13459.A.opSlice()`
|
||||||
---
|
---
|
||||||
*/
|
*/
|
||||||
struct A
|
struct A
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue