From c89013d607651b2d52a7483c956a137d86766dc2 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Wed, 19 Aug 2020 05:26:24 -0400 Subject: [PATCH] add test for malformed bracketed list missing closing brace --- src/parse/value/parse.rs | 4 +--- tests/error.rs | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/parse/value/parse.rs b/src/parse/value/parse.rs index 5effa3b..f461d9c 100644 --- a/src/parse/value/parse.rs +++ b/src/parse/value/parse.rs @@ -455,9 +455,7 @@ impl<'a> Parser<'a> { span = span.merge(inner.span); - if !matches!(self.toks.next(), Some(Token { kind: ']', .. })) { - return Err(("expected \"]\".", span).into()); - } + self.expect_char(']')?; IntermediateValue::Value(HigherIntermediateValue::Literal(match inner.node { Value::List(els, sep, Brackets::None) => Value::List(els, sep, Brackets::Bracketed), diff --git a/tests/error.rs b/tests/error.rs index 39bc9d3..fb7bb40 100644 --- a/tests/error.rs +++ b/tests/error.rs @@ -251,3 +251,7 @@ error!( nothing_after_escape_inside_brackets, "a { color: [\\", "Error: Expected expression." ); +error!( + unclosed_bracketed_list, + "a { color: [a", "Error: expected \"]\"." +);