From f766700000e1c50f400581fc647f71daef2bb588 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Mon, 15 Feb 2021 23:09:29 +0000 Subject: [PATCH] Remove unreachable warning for shift/exp operator --- libsolidity/analysis/TypeChecker.cpp | 21 +++++++-------------- scripts/error_codes.py | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 67cabcb63..830f3d458 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1636,20 +1636,13 @@ void TypeChecker::endVisit(BinaryOperation const& _operation) leftType->category() == Type::Category::RationalNumber && rightType->category() != Type::Category::RationalNumber ) - if (( - commonType->category() == Type::Category::Integer && - dynamic_cast(*commonType).numBits() != 256 - ) || ( - commonType->category() == Type::Category::FixedPoint && - dynamic_cast(*commonType).numBits() != 256 - )) - m_errorReporter.warning( - 9085_error, - _operation.location(), - "Result of " + operation + " has type " + commonType->toString() + " and thus " - "might overflow. Silence this warning by converting the literal to the " - "expected type." - ); + { + // These rules are enforced by the binary operator, but assert them here too. + if (auto type = dynamic_cast(commonType)) + solAssert(type->numBits() == 256, ""); + if (auto type = dynamic_cast(commonType)) + solAssert(type->numBits() == 256, ""); + } if ( commonType->category() == Type::Category::Integer && rightType->category() == Type::Category::Integer && diff --git a/scripts/error_codes.py b/scripts/error_codes.py index df6750a1f..e51f41e16 100755 --- a/scripts/error_codes.py +++ b/scripts/error_codes.py @@ -225,7 +225,7 @@ def examine_id_coverage(top_dir, source_id_to_file_names, new_ids_only=False): "3893", "3996", "4010", "4802", "5272", "5622", "7128", "7589", "7593", "8065", "8084", "8140", - "8312", "8592", "9085", "9609", + "8312", "8592", "9609", } new_source_only_ids = source_only_ids - old_source_only_ids