hyphen followed by interpolation is not treated as subtraction

This commit is contained in:
Connor Skees 2020-08-15 20:18:37 -04:00
parent 679bb94b53
commit 34dd92f78f
2 changed files with 11 additions and 1 deletions

View File

@ -850,6 +850,13 @@ impl<'a> Parser<'a> {
IntermediateValue::Op(Op::Plus).span(span)
}
'-' => {
if matches!(self.toks.peek(), Some(Token { kind: '#', .. }))
&& matches!(self.toks.peek_next(), Some(Token { kind: '{', .. }))
{
self.toks.reset_cursor();
return Some(self.parse_ident_value(predicate));
}
self.toks.reset_cursor();
let span = self.toks.next().unwrap().pos();
IntermediateValue::Op(Op::Minus).span(span)
}

View File

@ -192,7 +192,6 @@ test!(
"a {\n color: 0;\n}\n"
);
test!(
#[ignore]
sub_no_space_interpolation,
"a {\n color: 10-#{10};\n}\n",
"a {\n color: 10 -10;\n}\n"
@ -287,6 +286,10 @@ error!(
number_minus_color,
"a {\n color: 1 - #abc;\n}\n", "Error: Undefined operation \"1 - #abc\"."
);
error!(
number_minus_hex_color_no_space,
"a {\n color: 1-#abc;\n}\n", "Error: Undefined operation \"1 - #abc\"."
);
error!(
null_minus_function,
"a {\n color: null - get-function(lighten);\n}\n",