OPERATION (ANDAND, 2, logical_and_operation) \
OPERATION (OROR, 1, logical_or_operation)
+#define ASSIGN_PREC 0
+
operation_up start = parse_atom (required);
if (start == nullptr)
{
compound_assign_op = current_opcode;
/* FALLTHROUGH */
case '=':
- precedence = 0;
+ precedence = ASSIGN_PREC;
lex ();
break;
break;
}
- while (precedence <= operator_stack.back ().precedence
+ /* Make sure that assignments are right-associative while other
+ operations are left-associative. */
+ while ((precedence == ASSIGN_PREC
+ ? precedence < operator_stack.back ().precedence
+ : precedence <= operator_stack.back ().precedence)
&& operator_stack.size () > 1)
{
rustop_item rhs = std::move (operator_stack.back ());
# The new parser introduced an operator precedence bug.
gdb_test "print 5 * 7 / 5" " = 7"
gdb_test "print 4 - 3 - 1" " = 0"
+
+# Another operator precedence bug.
+gdb_test "print \$one = \$two = 75" " = \\\(\\\)"