From 253bc3b35ff3b8376d83fa38cc499704942cc732 Mon Sep 17 00:00:00 2001 From: Connor Skees Date: Sun, 16 Aug 2020 20:00:14 -0400 Subject: [PATCH] deny comma separated lists without parens as keys to map --- src/parse/value/parse.rs | 2 +- tests/map.rs | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/parse/value/parse.rs b/src/parse/value/parse.rs index 525e831..bc9e2b1 100644 --- a/src/parse/value/parse.rs +++ b/src/parse/value/parse.rs @@ -604,7 +604,7 @@ impl<'a> Parser<'a> { loop { let key = - self.parse_value(true, &|c| matches!(c.peek(), Some(Token { kind: ':', .. })))?; + self.parse_value(true, &|c| matches!(c.peek(), Some(Token { kind: ':', .. }) | Some(Token { kind: ',', .. })))?; self.expect_char(':')?; diff --git a/tests/map.rs b/tests/map.rs index c0c3cd0..2baa05c 100644 --- a/tests/map.rs +++ b/tests/map.rs @@ -225,3 +225,7 @@ error!( first_map_value_missing_closing_paren, "$a: (a: b", "Error: expected \")\"." ); +error!( + denies_comma_separated_list_without_parens_as_key, + "$map: (a: 1, b, c, d: e);", "Error: expected \":\"." +);