Browse Source

Merge pull request #655 from chriseth/sol_precedence

Bit operators should bind more strongly than comparison operators.
cl-refactor
chriseth 10 years ago
parent
commit
8a7a5d285e
  1. 20
      libsolidity/Token.h
  2. 10
      test/SolidityNameAndTypeResolution.cpp

20
libsolidity/Token.h

@ -107,9 +107,9 @@ namespace solidity
T(COMMA, ",", 1) \
T(OR, "||", 4) \
T(AND, "&&", 5) \
T(BIT_OR, "|", 6) \
T(BIT_XOR, "^", 7) \
T(BIT_AND, "&", 8) \
T(BIT_OR, "|", 8) \
T(BIT_XOR, "^", 9) \
T(BIT_AND, "&", 10) \
T(SHL, "<<", 11) \
T(SAR, ">>", 11) \
T(SHR, ">>>", 11) \
@ -122,13 +122,13 @@ namespace solidity
/* Compare operators sorted by precedence. */ \
/* IsCompareOp() relies on this block of enum values */ \
/* being contiguous and sorted in the same order! */ \
T(EQ, "==", 9) \
T(NE, "!=", 9) \
T(LT, "<", 10) \
T(GT, ">", 10) \
T(LTE, "<=", 10) \
T(GTE, ">=", 10) \
K(IN, "in", 10) \
T(EQ, "==", 6) \
T(NE, "!=", 6) \
T(LT, "<", 7) \
T(GT, ">", 7) \
T(LTE, "<=", 7) \
T(GTE, ">=", 7) \
K(IN, "in", 7) \
\
/* Unary operators. */ \
/* IsUnaryOp() relies on this block of enum values */ \

10
test/SolidityNameAndTypeResolution.cpp

@ -311,6 +311,16 @@ BOOST_AUTO_TEST_CASE(forward_function_reference)
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
BOOST_AUTO_TEST_CASE(comparison_bitop_precedence)
{
char const* text = "contract First {\n"
" function fun() returns (bool ret) {\n"
" return 1 & 2 == 8 & 9 && 1 ^ 2 < 4 | 6;\n"
" }\n"
"}\n";
BOOST_CHECK_NO_THROW(parseTextAndResolveNames(text));
}
BOOST_AUTO_TEST_SUITE_END()
}

Loading…
Cancel
Save