diff --git a/Changelog.md b/Changelog.md index d19d08be2..36ac87428 100644 --- a/Changelog.md +++ b/Changelog.md @@ -17,6 +17,7 @@ Bugfixes: * Type Checker: Disallow inline arrays of non-nameable types. * Type Checker: Fix internal compiler error when accessing members of array slices. * Type Checker: Fix internal compiler error when trying to decode too large static arrays. + * Type Checker: Fix wrong compiler error when referencing an overridden function without calling it. * NatSpec: DocString block is terminated when encountering an empty line. * Scanner: Fix bug when two empty NatSpec comments lead to scanning past EOL. * Code Generator: Trigger proper unimplemented errors on certain array copy operations. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 7681efc18..e6694043c 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -2981,7 +2981,11 @@ bool TypeChecker::visit(Identifier const& _identifier) if (!annotation.referencedDeclaration) { annotation.overloadedDeclarations = cleanOverloadedDeclarations(_identifier, annotation.candidateDeclarations); - if (!annotation.arguments) + if (annotation.overloadedDeclarations.empty()) + m_errorReporter.fatalTypeError(7593_error, _identifier.location(), "No candidates for overload resolution found."); + else if (annotation.overloadedDeclarations.size() == 1) + annotation.referencedDeclaration = *annotation.overloadedDeclarations.begin(); + else if (!annotation.arguments) { // The identifier should be a public state variable shadowing other functions vector candidates; @@ -2998,10 +3002,6 @@ bool TypeChecker::visit(Identifier const& _identifier) else m_errorReporter.fatalTypeError(7589_error, _identifier.location(), "No unique declaration found after variable lookup."); } - else if (annotation.overloadedDeclarations.empty()) - m_errorReporter.fatalTypeError(7593_error, _identifier.location(), "No candidates for overload resolution found."); - else if (annotation.overloadedDeclarations.size() == 1) - annotation.referencedDeclaration = *annotation.overloadedDeclarations.begin(); else { vector candidates; diff --git a/test/libsolidity/syntaxTests/inheritance/override/no_matching_resolution.sol b/test/libsolidity/syntaxTests/inheritance/override/no_matching_resolution.sol new file mode 100644 index 000000000..870f2b736 --- /dev/null +++ b/test/libsolidity/syntaxTests/inheritance/override/no_matching_resolution.sol @@ -0,0 +1,11 @@ +contract A { + function f() virtual internal {} +} +contract B is A { + function f() virtual override internal {} + function h() pure internal { f; } +} +contract C is B { + function f() override internal {} + function i() pure internal { f; } +}