fix regression involving min and max inside color functions

This commit is contained in:
Connor Skees 2020-07-29 08:27:53 -04:00
parent 6beb95ece0
commit f587a36367
4 changed files with 12 additions and 19 deletions

View File

@ -345,9 +345,9 @@ impl<'a> Parser<'a> {
None => return Err(("expected \")\".", span).into()),
}
}
Some(..) => {
Some(c) => {
value?;
unreachable!()
unreachable!("{:?}", c)
}
None => return Err(("expected \")\".", span).into()),
}

View File

@ -240,6 +240,8 @@ impl<'a> Parser<'a> {
')' => {
self.toks.advance_cursor();
buf.push(')');
// todo: https://github.com/foresterre/peekmore/issues/38
self.toks.peek();
return Ok(Some(buf));
}
'+' | '-' | '*' | '/' => {

View File

@ -268,25 +268,10 @@ impl<'a> Parser<'a> {
if let Some(Token { kind: '(', .. }) = self.toks.peek() {
self.toks.next();
if lower == "min" {
match self.try_parse_min_max("min", true)? {
if lower == "min" || lower == "max" {
match self.try_parse_min_max(&lower, true)? {
Some(val) => {
self.toks.truncate_iterator_to_cursor();
self.toks.next();
return Ok(IntermediateValue::Value(HigherIntermediateValue::Literal(
Value::String(val, QuoteKind::None),
))
.span(span));
}
None => {
self.toks.reset_cursor();
}
}
} else if lower == "max" {
match self.try_parse_min_max("max", true)? {
Some(val) => {
self.toks.truncate_iterator_to_cursor();
self.toks.next();
return Ok(IntermediateValue::Value(HigherIntermediateValue::Literal(
Value::String(val, QuoteKind::None),
))

View File

@ -674,3 +674,9 @@ error!(
alpha_filter_invalid_non_alphabetic_start,
"a {\n color: alpha(1=a);\n}\n", "Error: $color: 1=a is not a color."
);
// todo: we need many more of these tests
test!(
rgba_special_fn_4th_arg_max,
"a {\n color: rgba(1 2 max(3, 3));\n}\n",
"a {\n color: rgba(1, 2, max(3, 3));\n}\n"
);