handle -(null) and -null

This commit is contained in:
ConnorSkees 2020-04-18 20:45:40 -04:00
parent 305581ad75
commit 71546d7fc4
2 changed files with 14 additions and 8 deletions

View File

@ -229,17 +229,17 @@ fn eat_op<I: Iterator<Item = IntermediateValue>>(
span: left.span.merge(right.span),
});
} else {
space_separated.push(Spanned {
node: Value::UnaryOp(op.node, Box::new(right.node)),
span: right.span,
});
space_separated.push(right.map_node(|n| Value::UnaryOp(op.node, Box::new(n))));
}
} else {
let right = single_value(iter, scope, super_selector, op.span)?;
space_separated.push(Spanned {
node: Value::UnaryOp(op.node, Box::new(right.node)),
span: right.span,
});
if right.node == Value::Null {
space_separated.push(
right.map_node(|_| Value::Ident("-null".to_string(), QuoteKind::None)),
);
return Ok(());
}
space_separated.push(right.map_node(|n| Value::UnaryOp(op.node, Box::new(n))));
}
}
Op::And | Op::Or => {

View File

@ -50,3 +50,9 @@ test!(
"$a: 1;\n\na {\n color: -$a;\n}\n",
"a {\n color: -1;\n}\n"
);
test!(
unary_neg_null_paren,
"a {\n color: -(null);\n}\n",
"a {\n color: -;\n}\n"
);
test!(negative_null_as_ident, "a {\n color: -null;\n}\n");