Resolve NaN todo!()s for addition and subtraction with other numbers (#40)

* Replace todo's for propagating NaN

* Propagate NaN for remainder as well
This commit is contained in:
Midas Lambrichts 2020-09-14 00:08:41 +02:00 committed by GitHub
parent 8e060950d5
commit 7539762a0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -317,9 +317,9 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> {
format!("-{}", right.to_css_string(self.span)?),
QuoteKind::None,
),
Value::Dimension(None, ..) => todo!(),
v @ Value::Dimension(None, ..) => v,
Value::Dimension(Some(num), unit, _) => match right {
Value::Dimension(None, ..) => todo!(),
v @ Value::Dimension(None, ..) => v,
Value::Dimension(Some(num2), unit2, _) => {
if !unit.comparable(&unit2) {
return Err((
@ -643,9 +643,9 @@ impl<'a, 'b: 'a> ValueVisitor<'a, 'b> {
v => panic!("{:?}", v),
};
Ok(match left {
Value::Dimension(None, ..) => todo!(),
v @ Value::Dimension(None, ..) => v,
Value::Dimension(Some(n), u, _) => match right {
Value::Dimension(None, ..) => todo!(),
v @ Value::Dimension(None, ..) => v,
Value::Dimension(Some(n2), u2, _) => {
if !u.comparable(&u2) {
return Err(

View File

@ -282,6 +282,16 @@ test!(
"a {\n color: foo - red;\n}\n",
"a {\n color: foo-red;\n}\n"
);
test!(
sub_nan_left,
"a {\n left:0/0-0;\n}\n",
"a {\n left: NaN;\n}\n"
);
test!(
sub_nan_right,
"a {\n left:0-0/0;\n}\n",
"a {\n left: NaN;\n}\n"
);
error!(
number_minus_color,
"a {\n color: 1 - #abc;\n}\n", "Error: Undefined operation \"1 - #abc\"."