From 3ef510bc865a577b8e0936112f3178464af062fb Mon Sep 17 00:00:00 2001 From: a3d4 Date: Wed, 8 Apr 2020 23:40:29 +0200 Subject: [PATCH] Removed a redundant else clause. --- libsolidity/analysis/TypeChecker.cpp | 56 +++++++++++++--------------- 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 2bdc706a2..b2e49b052 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1430,41 +1430,37 @@ bool TypeChecker::visit(TupleExpression const& _tuple) { if (!components[i]) m_errorReporter.fatalTypeError(_tuple.location(), "Tuple component cannot be empty."); - else if (components[i]) - { - components[i]->accept(*this); - types.push_back(type(*components[i])); - if (types[i]->category() == Type::Category::Tuple) - if (dynamic_cast(*types[i]).components().empty()) - { - if (_tuple.isInlineArray()) - m_errorReporter.fatalTypeError(components[i]->location(), "Array component cannot be empty."); - m_errorReporter.typeError(components[i]->location(), "Tuple component cannot be empty."); - } + components[i]->accept(*this); + types.push_back(type(*components[i])); - // Note: code generation will visit each of the expression even if they are not assigned from. - if (types[i]->category() == Type::Category::RationalNumber && components.size() > 1) - if (!dynamic_cast(*types[i]).mobileType()) - m_errorReporter.fatalTypeError(components[i]->location(), "Invalid rational number."); - - if (_tuple.isInlineArray()) + if (types[i]->category() == Type::Category::Tuple) + if (dynamic_cast(*types[i]).components().empty()) { - solAssert(!!types[i], "Inline array cannot have empty components"); - - if ((i == 0 || inlineArrayType) && !types[i]->mobileType()) - m_errorReporter.fatalTypeError(components[i]->location(), "Invalid mobile type."); - - if (i == 0) - inlineArrayType = types[i]->mobileType(); - else if (inlineArrayType) - inlineArrayType = Type::commonType(inlineArrayType, types[i]); + if (_tuple.isInlineArray()) + m_errorReporter.fatalTypeError(components[i]->location(), "Array component cannot be empty."); + m_errorReporter.typeError(components[i]->location(), "Tuple component cannot be empty."); } - if (!components[i]->annotation().isPure) - isPure = false; + + // Note: code generation will visit each of the expression even if they are not assigned from. + if (types[i]->category() == Type::Category::RationalNumber && components.size() > 1) + if (!dynamic_cast(*types[i]).mobileType()) + m_errorReporter.fatalTypeError(components[i]->location(), "Invalid rational number."); + + if (_tuple.isInlineArray()) + { + solAssert(!!types[i], "Inline array cannot have empty components"); + + if ((i == 0 || inlineArrayType) && !types[i]->mobileType()) + m_errorReporter.fatalTypeError(components[i]->location(), "Invalid mobile type."); + + if (i == 0) + inlineArrayType = types[i]->mobileType(); + else if (inlineArrayType) + inlineArrayType = Type::commonType(inlineArrayType, types[i]); } - else - types.push_back(TypePointer()); + if (!components[i]->annotation().isPure) + isPure = false; } _tuple.annotation().isPure = isPure; if (_tuple.isInlineArray())