mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Validate each tuple literal
This commit is contained in:
parent
c67b559ead
commit
c99d2aae04
@ -22,6 +22,7 @@ Bugfixes:
|
|||||||
* Type Checker: Prevent duplicate event declarations.
|
* Type Checker: Prevent duplicate event declarations.
|
||||||
* Type Checker: Do not mark event parameters as shadowing state variables.
|
* Type Checker: Do not mark event parameters as shadowing state variables.
|
||||||
* Type Checker: Allow ``gas`` in view functions.
|
* Type Checker: Allow ``gas`` in view functions.
|
||||||
|
* Type Checker: Validate each number literal in tuple expressions even if they are not assigned from.
|
||||||
|
|
||||||
### 0.4.17 (2017-09-21)
|
### 0.4.17 (2017-09-21)
|
||||||
|
|
||||||
|
@ -1293,6 +1293,12 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
|
|||||||
{
|
{
|
||||||
components[i]->accept(*this);
|
components[i]->accept(*this);
|
||||||
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.
|
||||||
|
if (types[i]->category() == Type::Category::RationalNumber)
|
||||||
|
if (!dynamic_cast<RationalNumberType const&>(*types[i]).mobileType())
|
||||||
|
m_errorReporter.fatalTypeError(components[i]->location(), "Invalid rational number.");
|
||||||
|
|
||||||
if (_tuple.isInlineArray())
|
if (_tuple.isInlineArray())
|
||||||
solAssert(!!types[i], "Inline array cannot have empty components");
|
solAssert(!!types[i], "Inline array cannot have empty components");
|
||||||
if (_tuple.isInlineArray())
|
if (_tuple.isInlineArray())
|
||||||
|
@ -5537,7 +5537,7 @@ BOOST_AUTO_TEST_CASE(invalid_mobile_type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_ERROR(text, TypeError, "Invalid mobile type.");
|
CHECK_ERROR(text, TypeError, "Invalid rational number.");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(warns_msg_value_in_non_payable_public_function)
|
BOOST_AUTO_TEST_CASE(warns_msg_value_in_non_payable_public_function)
|
||||||
@ -7096,6 +7096,37 @@ BOOST_AUTO_TEST_CASE(non_external_fallback)
|
|||||||
CHECK_ERROR(text, TypeError, "Fallback function must be defined as \"external\".");
|
CHECK_ERROR(text, TypeError, "Fallback function must be defined as \"external\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(invalid_literal_in_tuple)
|
||||||
|
{
|
||||||
|
char const* text = R"(
|
||||||
|
contract C {
|
||||||
|
function f() pure public {
|
||||||
|
uint x;
|
||||||
|
(x, ) = (1E111);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR(text, TypeError, "Invalid rational number.");
|
||||||
|
text = R"(
|
||||||
|
contract C {
|
||||||
|
function f() pure public {
|
||||||
|
uint x;
|
||||||
|
(x, ) = (1, 1E111);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR(text, TypeError, "Invalid rational number.");
|
||||||
|
text = R"(
|
||||||
|
contract C {
|
||||||
|
function f() pure public {
|
||||||
|
uint x;
|
||||||
|
(x, ) = (1E111, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
CHECK_ERROR(text, TypeError, "Invalid rational number.");
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(warn_about_sha3)
|
BOOST_AUTO_TEST_CASE(warn_about_sha3)
|
||||||
{
|
{
|
||||||
char const* text = R"(
|
char const* text = R"(
|
||||||
|
Loading…
Reference in New Issue
Block a user