allow negative numbers multiplication

This commit is contained in:
ConnorSkees 2020-03-30 00:38:46 -04:00
parent 8f96a821f7
commit 6608fe3f2f
2 changed files with 6 additions and 0 deletions

View File

@ -214,6 +214,7 @@ impl Mul for Value {
} }
}, },
Self::BinaryOp(..) | Self::Paren(..) => self.eval()?, Self::BinaryOp(..) | Self::Paren(..) => self.eval()?,
Self::UnaryOp(..) => (self.eval()? * other)?,
_ => return Err(format!("Undefined operation \"{} * {}\".", self, other).into()), _ => return Err(format!("Undefined operation \"{} * {}\".", self, other).into()),
}) })
} }

View File

@ -463,3 +463,8 @@ test!(
"a {\n color: (a b) - (1 2);\n}\n", "a {\n color: (a b) - (1 2);\n}\n",
"a {\n color: a b-1 2;\n}\n" "a {\n color: a b-1 2;\n}\n"
); );
test!(
negative_number_times_number,
"a {\n color: -1 * 2;\n}\n",
"a {\n color: -2;\n}\n"
);