when two operators have the same precedence, evaluate the leftmost first
This commit is contained in:
parent
30a3a46b2d
commit
ca2938f04c
@ -68,7 +68,7 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> {
|
||||
let val2 = self.paren_or_unary(val2)?;
|
||||
|
||||
if let HigherIntermediateValue::BinaryOp(val1_1, op2, val1_2) = val1 {
|
||||
if op2.precedence() > op.precedence() {
|
||||
if op2.precedence() >= op.precedence() {
|
||||
val1 = HigherIntermediateValue::Literal(self.bin_op(*val1_1, op2, *val1_2)?);
|
||||
} else {
|
||||
let val2 = HigherIntermediateValue::Literal(self.bin_op(*val1_2, op, val2)?);
|
||||
|
@ -90,7 +90,7 @@ test!(
|
||||
test!(
|
||||
max_evaluated_binop,
|
||||
"a {\n color: max(100% - lightness(red) - 2%);\n}\n",
|
||||
"a {\n color: 52%;\n}\n"
|
||||
"a {\n color: 48%;\n}\n"
|
||||
);
|
||||
error!(
|
||||
max_arg_of_incorrect_type,
|
||||
|
@ -38,3 +38,8 @@ test!(
|
||||
"a {\n color: a or b !=c;\n}\n",
|
||||
"a {\n color: a;\n}\n"
|
||||
);
|
||||
test!(
|
||||
leftmost_is_evaluated_first_when_same_precedence,
|
||||
"a {\n color: 1 / 2 * 1em;\n}\n",
|
||||
"a {\n color: 0.5em;\n}\n"
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user