aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/SolidityNameAndTypeResolution.cpp
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2015-08-06 21:33:06 +0800
committerchriseth <c@ethdev.com>2015-08-07 23:50:07 +0800
commite0fbdd57e6ca44472850c05a74f56c7ed555cf2d (patch)
tree849c7f75685d9736c06b81dca45e859cdf0495e0 /libsolidity/SolidityNameAndTypeResolution.cpp
parent46381f9e91073c6b521f1ef07b29df905c5be022 (diff)
downloaddexon-solidity-e0fbdd57e6ca44472850c05a74f56c7ed555cf2d.tar.gz
dexon-solidity-e0fbdd57e6ca44472850c05a74f56c7ed555cf2d.tar.zst
dexon-solidity-e0fbdd57e6ca44472850c05a74f56c7ed555cf2d.zip
Do not allow boolean operators for integers.
Fixes #2496
Diffstat (limited to 'libsolidity/SolidityNameAndTypeResolution.cpp')
-rw-r--r--libsolidity/SolidityNameAndTypeResolution.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp
index 6b116f25..e59217bf 100644
--- a/libsolidity/SolidityNameAndTypeResolution.cpp
+++ b/libsolidity/SolidityNameAndTypeResolution.cpp
@@ -1883,6 +1883,22 @@ BOOST_AUTO_TEST_CASE(positive_integers_to_unsigned_out_of_bound)
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode), TypeError);
}
+BOOST_AUTO_TEST_CASE(integer_boolean_operators)
+{
+ char const* sourceCode1 = R"(
+ contract test { function() { uint x = 1; uint y = 2; x || y; } }
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode1), TypeError);
+ char const* sourceCode2 = R"(
+ contract test { function() { uint x = 1; uint y = 2; x && y; } }
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode2), TypeError);
+ char const* sourceCode3 = R"(
+ contract test { function() { uint x = 1; !x; } }
+ )";
+ BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode3), TypeError);
+}
+
BOOST_AUTO_TEST_CASE(overwrite_memory_location_external)
{
char const* sourceCode = R"(