@@ -1101,7 +1101,7 @@ class CandidateFunctions {
11011101 default : break ;
11021102 }
11031103
1104- int ambiguity = 0 ;
1104+ int ambiguity = - 1 ;
11051105 std::pair<const Candidate*, int > c = { nullptr , -1 };
11061106 for (auto & candidate : m_candidates) {
11071107 // re-score based on matching return value
@@ -1111,7 +1111,7 @@ class CandidateFunctions {
11111111 ambiguity = candidate.rscore ;
11121112 }
11131113
1114- if (ambiguity || strict) {
1114+ if (( ambiguity != - 1 ) || strict) {
11151115 ASSERT (caller);
11161116 caller->warning ( " call to '%s' is ambiguous" , m_candidates[0 ].name ());
11171117 for (auto & candidate : m_candidates) {
@@ -1392,6 +1392,9 @@ ASTfunction_call::typecheck (TypeSpec expected)
13921392 return typecheck_struct_constructor ();
13931393 }
13941394
1395+ // Save the current symbol to maybe report an error later.
1396+ FunctionSymbol *poly = func ();
1397+
13951398 CandidateFunctions candidates (m_compiler, expected, args (), func ());
13961399 std::tie (m_sym, m_typespec) = candidates.best (this );
13971400
@@ -1418,8 +1421,10 @@ ASTfunction_call::typecheck (TypeSpec expected)
14181421 // message.
14191422 candidates.reportError (this , m_name);
14201423
1421- for (FunctionSymbol * poly = func (); poly; poly = poly-> nextpoly ())
1424+ while ( poly) {
14221425 candidates.reportAmbiguity (poly);
1426+ poly = poly->nextpoly ();
1427+ }
14231428
14241429 return TypeSpec ();
14251430}
0 commit comments