resolve map parsing regression involving trailing commas in doubly nested maps
This commit is contained in:
parent
56030f1292
commit
a3a21928c0
@ -444,12 +444,9 @@ impl<'a> Parser<'a> {
|
||||
&|c| matches!(c.peek(), Some(Token { kind: ':', .. }) | Some(Token { kind: ')', .. })),
|
||||
)?;
|
||||
|
||||
match self.toks.peek() {
|
||||
Some(Token { kind: ':', .. }) => {
|
||||
self.toks.next();
|
||||
}
|
||||
match self.toks.next() {
|
||||
Some(Token { kind: ':', .. }) => {}
|
||||
Some(Token { kind: ')', .. }) => {
|
||||
self.toks.next();
|
||||
return Ok(Spanned {
|
||||
node: IntermediateValue::Value(HigherIntermediateValue::Literal(key.node)),
|
||||
span: key.span,
|
||||
@ -509,19 +506,18 @@ impl<'a> Parser<'a> {
|
||||
return Err(("Duplicate key.", key.span).into());
|
||||
}
|
||||
|
||||
match self.toks.next() {
|
||||
Some(Token { kind: ',', .. }) => {}
|
||||
let found_comma = self.consume_char_if_exists(',');
|
||||
|
||||
self.whitespace_or_comment();
|
||||
|
||||
match self.toks.peek() {
|
||||
Some(Token { kind: ')', .. }) => {
|
||||
self.toks.next();
|
||||
break;
|
||||
}
|
||||
Some(..) if found_comma => continue,
|
||||
Some(..) | None => return Err(("expected \")\".", val.span).into()),
|
||||
}
|
||||
|
||||
self.whitespace_or_comment();
|
||||
|
||||
while self.consume_char_if_exists(',') {
|
||||
self.whitespace_or_comment();
|
||||
}
|
||||
}
|
||||
Ok(Spanned {
|
||||
node: IntermediateValue::Value(HigherIntermediateValue::Literal(Value::Map(map))),
|
||||
|
10
tests/map.rs
10
tests/map.rs
@ -205,6 +205,16 @@ test!(
|
||||
}",
|
||||
"a {\n color: ();\n}\n"
|
||||
);
|
||||
test!(
|
||||
trailing_comma_in_doubly_nested_map,
|
||||
r#"$a: (
|
||||
foo: (
|
||||
a: b,
|
||||
c: d,
|
||||
)
|
||||
);"#,
|
||||
""
|
||||
);
|
||||
error!(
|
||||
second_map_value_missing_colon,
|
||||
"a {\n color: (a: b, c", "Error: expected \":\"."
|
||||
|
Loading…
x
Reference in New Issue
Block a user