diff options
author | chriseth <chris@ethereum.org> | 2018-05-02 21:56:06 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-02 21:56:06 +0800 |
commit | 42289b642ff12d9275dedf10c257cfec8295feed (patch) | |
tree | 387ecf7c3325763bc46485ef183f0df3f608b1d8 /libsolidity | |
parent | 451e8edb1a095a8958eba96a0435ff9fb9ffb2a9 (diff) | |
parent | d43436cfec7cb1820f8f588a8a877e1cbf48b919 (diff) | |
download | dexon-solidity-42289b642ff12d9275dedf10c257cfec8295feed.tar.gz dexon-solidity-42289b642ff12d9275dedf10c257cfec8295feed.tar.zst dexon-solidity-42289b642ff12d9275dedf10c257cfec8295feed.zip |
Merge pull request #4003 from ethereum/bool_vars_comparison
BREAKING: Bool variables should not allow arithmetic comparison
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/ast/Types.cpp | 2 | ||||
-rw-r--r-- | libsolidity/formal/SMTChecker.cpp | 6 |
2 files changed, 2 insertions, 6 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 11d7160c..f4198016 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -1359,7 +1359,7 @@ TypePointer BoolType::binaryOperatorResult(Token::Value _operator, TypePointer c { if (category() != _other->category()) return TypePointer(); - if (Token::isCompareOp(_operator) || _operator == Token::And || _operator == Token::Or) + if (_operator == Token::Equal || _operator == Token::NotEqual || _operator == Token::And || _operator == Token::Or) return _other; else return TypePointer(); diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp index c4dee22d..7facdf92 100644 --- a/libsolidity/formal/SMTChecker.cpp +++ b/libsolidity/formal/SMTChecker.cpp @@ -472,11 +472,7 @@ void SMTChecker::compareOperation(BinaryOperation const& _op) solUnimplementedAssert(SSAVariable::isBool(_op.annotation().commonType->category()), "Operation not yet supported"); value = make_shared<smt::Expression>( op == Token::Equal ? (left == right) : - op == Token::NotEqual ? (left != right) : - op == Token::LessThan ? (!left && right) : - op == Token::LessThanOrEqual ? (!left || right) : - op == Token::GreaterThan ? (left && !right) : - /*op == Token::GreaterThanOrEqual*/ (left || !right) + /*op == Token::NotEqual*/ (left != right) ); } // TODO: check that other values for op are not possible. |