aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2017-10-18 17:59:40 +0800
committerGitHub <noreply@github.com>2017-10-18 17:59:40 +0800
commite854da1a8c2253704e412214e8115fd1c1c819f2 (patch)
treeedc7f6a7cd392ee4681c16536f7692a05a4f1de4 /test
parente247524bd563371e2ed2b871a0185ad033c1de24 (diff)
parent8a8a71de84f5bd71fcea4d31d5a53fde7820ead6 (diff)
downloaddexon-solidity-e854da1a8c2253704e412214e8115fd1c1c819f2.tar.gz
dexon-solidity-e854da1a8c2253704e412214e8115fd1c1c819f2.tar.zst
dexon-solidity-e854da1a8c2253704e412214e8115fd1c1c819f2.zip
Merge pull request #2925 from ethereum/tuple-value-check
Validate each tuple literal
Diffstat (limited to 'test')
-rw-r--r--test/libsolidity/SolidityNameAndTypeResolution.cpp49
1 files changed, 48 insertions, 1 deletions
diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp
index 2c720d03..9b0647bf 100644
--- a/test/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -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)
@@ -7096,6 +7096,53 @@ BOOST_AUTO_TEST_CASE(non_external_fallback)
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, "is not implicitly convertible to expected type");
+ 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.");
+ 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)
{
char const* text = R"(