mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix type identifiers for RationalNumberType
This commit is contained in:
parent
9d3827266c
commit
b0f9fc5af0
@ -79,6 +79,7 @@ Compiler Features:
|
||||
Bugfixes:
|
||||
* Tests: Fix chain parameters to make ipc tests work with newer versions of cpp-ethereum.
|
||||
* Code Generator: Fix allocation of byte arrays (zeroed out too much memory).
|
||||
* Code Generator: Properly handle negative number literals in ABIEncoderV2.
|
||||
* Commandline Interface: Correctly handle paths with backslashes on windows.
|
||||
* Fix NatSpec json output for `@notice` and `@dev` tags on contract definitions.
|
||||
* References Resolver: Do not crash on using ``_slot`` and ``_offset`` suffixes on their own.
|
||||
|
@ -1146,7 +1146,14 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
|
||||
|
||||
string RationalNumberType::richIdentifier() const
|
||||
{
|
||||
return "t_rational_" + m_value.numerator().str() + "_by_" + m_value.denominator().str();
|
||||
// rational seemingly will put the sign always on the numerator,
|
||||
// but let just make it deterministic here.
|
||||
bigint numerator = abs(m_value.numerator());
|
||||
bigint denominator = abs(m_value.denominator());
|
||||
if (m_value < 0)
|
||||
return "t_rational_minus_" + numerator.str() + "_by_" + denominator.str();
|
||||
else
|
||||
return "t_rational_" + numerator.str() + "_by_" + denominator.str();
|
||||
}
|
||||
|
||||
bool RationalNumberType::operator==(Type const& _other) const
|
||||
|
@ -157,6 +157,9 @@ BOOST_AUTO_TEST_CASE(type_identifiers)
|
||||
BOOST_CHECK_EQUAL(RationalNumberType(rational(7, 1)).identifier(), "t_rational_7_by_1");
|
||||
BOOST_CHECK_EQUAL(RationalNumberType(rational(200, 77)).identifier(), "t_rational_200_by_77");
|
||||
BOOST_CHECK_EQUAL(RationalNumberType(rational(2 * 200, 2 * 77)).identifier(), "t_rational_200_by_77");
|
||||
BOOST_CHECK_EQUAL(RationalNumberType(rational(-2 * 200, -2 * 77)).identifier(), "t_rational_200_by_77");
|
||||
BOOST_CHECK_EQUAL(RationalNumberType(rational(-2 * 200, 2 * 77)).identifier(), "t_rational_minus_200_by_77");
|
||||
BOOST_CHECK_EQUAL(RationalNumberType(rational(2 * 200, -2 * 77)).identifier(), "t_rational_minus_200_by_77");
|
||||
BOOST_CHECK_EQUAL(
|
||||
StringLiteralType(Literal(SourceLocation{}, Token::StringLiteral, make_shared<string>("abc - def"))).identifier(),
|
||||
"t_stringliteral_196a9142ee0d40e274a6482393c762b16dd8315713207365e1e13d8d85b74fc4"
|
||||
|
Loading…
Reference in New Issue
Block a user