diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index ca8c44592..36cf90ab0 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -39,6 +39,8 @@ #include #include +#include + #include #include @@ -980,18 +982,17 @@ void TypeChecker::endVisit(TryStatement const& _tryStatement) to_string(parameters.size()) + " variables." ); - size_t len = min(returnTypes.size(), parameters.size()); - for (size_t i = 0; i < len; ++i) + for (auto&& [parameter, returnType]: ranges::views::zip(parameters, returnTypes)) { - solAssert(returnTypes[i], ""); - if (parameters[i] && *parameters[i]->annotation().type != *returnTypes[i]) + solAssert(returnType, ""); + if (parameter && *parameter->annotation().type != *returnType) m_errorReporter.typeError( 6509_error, - parameters[i]->location(), + parameter->location(), "Invalid type, expected " + - returnTypes[i]->toString(false) + + returnType->toString(false) + " but got " + - parameters[i]->annotation().type->toString() + + parameter->annotation().type->toString() + "." ); }