From 15df2b30d76a448fabe7b7a0890762291b17e503 Mon Sep 17 00:00:00 2001 From: Mathias Baumann Date: Wed, 13 Nov 2019 14:24:48 +0100 Subject: [PATCH] List candidates when overload failed fixes #7146 --- Changelog.md | 1 + libsolidity/analysis/TypeChecker.cpp | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Changelog.md b/Changelog.md index c47a0dc1a..db26a995f 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ Compiler Features: * SMTChecker: Add break/continue support to the CHC engine. * SMTChecker: Support assignments to multi-dimensional arrays and mappings. * SMTChecker: Support inheritance and function overriding. + * TypeChecker: List possible candidates when overload resolution fails * EWasm: Experimental EWasm binary output. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 5fc201b70..469ea830b 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2352,12 +2352,19 @@ bool TypeChecker::visit(Identifier const& _identifier) if (functionType->canTakeArguments(*annotation.arguments)) candidates.push_back(declaration); } - if (candidates.empty()) - m_errorReporter.fatalTypeError(_identifier.location(), "No matching declaration found after argument-dependent lookup."); - else if (candidates.size() == 1) + if (candidates.size() == 1) annotation.referencedDeclaration = candidates.front(); else - m_errorReporter.fatalTypeError(_identifier.location(), "No unique declaration found after argument-dependent lookup."); + { + SecondarySourceLocation ssl; + + for (Declaration const* declaration: annotation.overloadedDeclarations) + ssl.append("Candidate:", declaration->location()); + if (candidates.empty()) + m_errorReporter.fatalTypeError(_identifier.location(), ssl, "No matching declaration found after argument-dependent lookup."); + else + m_errorReporter.fatalTypeError(_identifier.location(), ssl, "No unique declaration found after argument-dependent lookup."); + } } } solAssert(