diff options
author | Gav Wood <g@ethdev.com> | 2015-08-11 02:25:03 +0800 |
---|---|---|
committer | Gav Wood <g@ethdev.com> | 2015-08-11 02:25:03 +0800 |
commit | 0d66d8cf7c25708c24a823c2e5fc62e762251d61 (patch) | |
tree | 69d696198474e87b0960ab31d618459f6f28e8ef | |
parent | ec57873f58c5d663a0e233246ab4bb8cbc9bc0f2 (diff) | |
parent | 4288543847307de17d7fbde393a1a3f647be5f05 (diff) | |
download | dexon-solidity-0d66d8cf7c25708c24a823c2e5fc62e762251d61.tar dexon-solidity-0d66d8cf7c25708c24a823c2e5fc62e762251d61.tar.gz dexon-solidity-0d66d8cf7c25708c24a823c2e5fc62e762251d61.tar.bz2 dexon-solidity-0d66d8cf7c25708c24a823c2e5fc62e762251d61.tar.lz dexon-solidity-0d66d8cf7c25708c24a823c2e5fc62e762251d61.tar.xz dexon-solidity-0d66d8cf7c25708c24a823c2e5fc62e762251d61.tar.zst dexon-solidity-0d66d8cf7c25708c24a823c2e5fc62e762251d61.zip |
Merge pull request #2734 from chriseth/sol_fixOperators
Disallow some binary operators.
-rw-r--r-- | libsolidity/SolidityNameAndTypeResolution.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/libsolidity/SolidityNameAndTypeResolution.cpp b/libsolidity/SolidityNameAndTypeResolution.cpp index 6b116f25..ba5a5a60 100644 --- a/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/libsolidity/SolidityNameAndTypeResolution.cpp @@ -1883,6 +1883,34 @@ 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(reference_compare_operators) +{ + char const* sourceCode1 = R"( + contract test { bytes a; bytes b; function() { a == b; } } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode1), TypeError); + char const* sourceCode2 = R"( + contract test { struct s {uint a;}; s x; s y; function() { x == y; } } + )"; + BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode2), TypeError); +} + BOOST_AUTO_TEST_CASE(overwrite_memory_location_external) { char const* sourceCode = R"( |