fix panic when missing colon in style
This commit is contained in:
parent
b58ed29fd0
commit
f8b8025d7c
@ -190,21 +190,20 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
|
||||
span = span.merge(tok.pos());
|
||||
match tok.kind {
|
||||
':' => {
|
||||
let tok = toks.next();
|
||||
let tok = toks.next().unwrap();
|
||||
values.push(tok);
|
||||
if devour_whitespace(toks) {
|
||||
let prop = Style::parse_property(
|
||||
&mut values.into_iter().peekmore(),
|
||||
scope,
|
||||
super_selector,
|
||||
String::new(),
|
||||
tok.unwrap().pos,
|
||||
tok.pos,
|
||||
)?;
|
||||
return Ok(Some(Spanned {
|
||||
node: Style::from_tokens(toks, scope, super_selector, prop)?,
|
||||
span,
|
||||
}));
|
||||
} else {
|
||||
values.push(tok.unwrap());
|
||||
}
|
||||
}
|
||||
';' => {
|
||||
|
10
src/style.rs
10
src/style.rs
@ -199,19 +199,21 @@ impl<'a> StyleParser<'a> {
|
||||
span_before: Span,
|
||||
) -> SassResult<String> {
|
||||
devour_whitespace(toks);
|
||||
let property = eat_ident(toks, self.scope, self.super_selector, span_before)?.node;
|
||||
let property = eat_ident(toks, self.scope, self.super_selector, span_before)?;
|
||||
devour_whitespace_or_comment(toks)?;
|
||||
if toks.peek().is_some() && toks.peek().unwrap().kind == ':' {
|
||||
toks.next();
|
||||
devour_whitespace_or_comment(toks)?;
|
||||
} else {
|
||||
return Err(("Expected \":\".", property.span).into());
|
||||
}
|
||||
|
||||
if super_property.is_empty() {
|
||||
Ok(property)
|
||||
Ok(property.node)
|
||||
} else {
|
||||
super_property.reserve(1 + property.len());
|
||||
super_property.reserve(1 + property.node.len());
|
||||
super_property.push('-');
|
||||
super_property.push_str(&property);
|
||||
super_property.push_str(&property.node);
|
||||
Ok(super_property)
|
||||
}
|
||||
}
|
||||
|
@ -62,3 +62,7 @@ error!(
|
||||
nothing_after_at_sign,
|
||||
"a {color: red; @", "Error: Expected identifier."
|
||||
);
|
||||
error!(
|
||||
missing_colon_in_style,
|
||||
"a {color, red;}", "Error: Expected \":\"."
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user