mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Only check tuples for valid rational numbers if they have more than one element.
This commit is contained in:
parent
c99d2aae04
commit
8a8a71de84
@ -1295,7 +1295,7 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
|
|||||||
types.push_back(type(*components[i]));
|
types.push_back(type(*components[i]));
|
||||||
|
|
||||||
// Note: code generation will visit each of the expression even if they are not assigned from.
|
// Note: code generation will visit each of the expression even if they are not assigned from.
|
||||||
if (types[i]->category() == Type::Category::RationalNumber)
|
if (types[i]->category() == Type::Category::RationalNumber && components.size() > 1)
|
||||||
if (!dynamic_cast<RationalNumberType const&>(*types[i]).mobileType())
|
if (!dynamic_cast<RationalNumberType const&>(*types[i]).mobileType())
|
||||||
m_errorReporter.fatalTypeError(components[i]->location(), "Invalid rational number.");
|
m_errorReporter.fatalTypeError(components[i]->location(), "Invalid rational number.");
|
||||||
|
|
||||||
|
@ -7106,7 +7106,7 @@ BOOST_AUTO_TEST_CASE(invalid_literal_in_tuple)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Invalid rational number.");
|
CHECK_ERROR(text, TypeError, "is not implicitly convertible to expected type");
|
||||||
text = R"(
|
text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function f() pure public {
|
function f() pure public {
|
||||||
@ -7125,6 +7125,22 @@ BOOST_AUTO_TEST_CASE(invalid_literal_in_tuple)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Invalid rational number.");
|
CHECK_ERROR(text, TypeError, "Invalid rational number.");
|
||||||
|
text = R"(
|
||||||
|
contract C {
|
||||||
|
function f() pure public {
|
||||||
|
(2**270, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR(text, TypeError, "Invalid rational number.");
|
||||||
|
text = R"(
|
||||||
|
contract C {
|
||||||
|
function f() pure public {
|
||||||
|
((2**270) / 2**100, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_SUCCESS(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(warn_about_sha3)
|
BOOST_AUTO_TEST_CASE(warn_about_sha3)
|
||||||
|
Loading…
Reference in New Issue
Block a user