diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 716a12045..e4b7e4fd8 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -949,25 +949,25 @@ bool RationalNumberType::operator==(Type const& _other) const return m_value == other.m_value; } -string RationalNumberType::bigintToString(dev::bigint const& _num, bool _short) +string RationalNumberType::bigintToReadableString(dev::bigint const& _num) { string str = _num.str(); - if (_short && str.size() > 32) + if (str.size() > 32) { int omitted = str.size() - 8; - return str.substr(0, 4) + "...(" + to_string(omitted) + " digits omitted)..." + str.substr(str.size() - 4, 4); + str = str.substr(0, 4) + "...(" + to_string(omitted) + " digits omitted)..." + str.substr(str.size() - 4, 4); } return str; } -string RationalNumberType::toString(bool _short) const +string RationalNumberType::toString(bool) const { if (!isFractional()) - return "int_const " + bigintToString(m_value.numerator(), _short); + return "int_const " + bigintToReadableString(m_value.numerator()); - string numerator = bigintToString(m_value.numerator(), _short); - string denominator = bigintToString(m_value.denominator(), _short); - return "rational_const " + numerator + '/' + denominator; + string numerator = bigintToReadableString(m_value.numerator()); + string denominator = bigintToReadableString(m_value.denominator()); + return "rational_const " + numerator + " / " + denominator; } u256 RationalNumberType::literalValue(Literal const*) const diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h index 05f23d040..2e7d05ba9 100644 --- a/libsolidity/ast/Types.h +++ b/libsolidity/ast/Types.h @@ -440,7 +440,7 @@ private: /// @returns a truncated readable representation of the bigint keeping only /// up to 4 leading and 4 trailing digits. - static std::string bigintToString(dev::bigint const& num, bool _short); + static std::string bigintToReadableString(dev::bigint const& num); }; /** diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 871806fa5..4eade7f1e 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -4574,7 +4574,7 @@ BOOST_AUTO_TEST_CASE(rational_index_access) } } )"; - CHECK_ERROR(text, TypeError, "rational_const 1/2 is not implicitly convertible to expected type uint256"); + CHECK_ERROR(text, TypeError, "rational_const 1 / 2 is not implicitly convertible to expected type uint256"); } BOOST_AUTO_TEST_CASE(rational_to_fixed_literal_expression)