emit proper error for map as lhs of addition

This commit is contained in:
ConnorSkees 2020-05-22 20:34:41 -04:00
parent 368f0cf596
commit 80e32b4290
2 changed files with 16 additions and 2 deletions

View File

@ -256,7 +256,14 @@ impl Value {
}
let precedence = Op::Plus.precedence();
Ok(match self {
Self::Function(..) | Self::ArgList(..) | Self::Map(..) => todo!(),
Self::Map(..) => {
return Err((
format!("{} isn't a valid CSS value.", self.inspect(span)?),
span,
)
.into())
}
Self::Function(..) | Self::ArgList(..) => todo!(),
Self::Important | Self::True | Self::False => match other {
Self::String(s, QuoteKind::Quoted) => Value::String(
format!("{}{}", self.to_css_string(span)?, s),

View File

@ -124,7 +124,10 @@ error!(
);
error!(toplevel_hash, "#", "Error: expected \"{\".");
error!(toplevel_at, "@", "Error: Expected identifier.");
error!(toplevel_ampersand, "& {}", "Error: Top-level selectors may not contain the parent selector \"&\".");
error!(
toplevel_ampersand,
"& {}", "Error: Top-level selectors may not contain the parent selector \"&\"."
);
error!(toplevel_backslash, "\\", "Error: expected \"}\".");
error!(toplevel_var_no_colon, "$r", "Error: expected \":\".");
error!(bar_in_value, "a {color: a|b;}", "Error: expected \";\".");
@ -164,3 +167,7 @@ error!(
operator_mul,
"a {color: 5 - *;}", "Error: Expected expression."
);
error!(
map_lhs_add,
"a {color: (a: b) + 1;}", "Error: (a: b) isn't a valid CSS value."
);