From a903982e17812b361a77555597c506bb20657f5f Mon Sep 17 00:00:00 2001 From: stefan-gorules <127550877+stefan-gorules@users.noreply.github.com> Date: Tue, 10 Sep 2024 15:48:56 +0200 Subject: [PATCH] fix: empty object (#241) --- core/expression/src/parser/parser.rs | 5 +++++ core/expression/tests/data/standard.csv | 1 + 2 files changed, 6 insertions(+) diff --git a/core/expression/src/parser/parser.rs b/core/expression/src/parser/parser.rs index 62a9bf2c..d3ca0500 100644 --- a/core/expression/src/parser/parser.rs +++ b/core/expression/src/parser/parser.rs @@ -489,7 +489,12 @@ impl<'arena, 'token_ref, Flavor> Parser<'arena, 'token_ref, Flavor> { F: Fn() -> ParserResult<&'arena Node<'arena>>, { self.expect(TokenKind::Bracket(Bracket::LeftCurlyBracket))?; + let mut key_value_pairs = BumpVec::new_in(self.bump); + if let TokenKind::Bracket(Bracket::RightCurlyBracket) = self.current().kind { + self.next()?; + return Ok(self.node(Node::Object(key_value_pairs.into_bump_slice()))); + } loop { let key = self.object_key(&expression_parser)?; diff --git a/core/expression/tests/data/standard.csv b/core/expression/tests/data/standard.csv index 1c1c8a70..cecf19f6 100644 --- a/core/expression/tests/data/standard.csv +++ b/core/expression/tests/data/standard.csv @@ -271,6 +271,7 @@ keys(customer);{"customer": {"firstName": "John"}};["firstName"] keys(customer);{"customer": {"lastName": "Doe"}};["lastName"] values(customer);{"customer": {"firstName": "John"}};["John"] values(customer);{"customer": {"lastName": "Doe"}};["Doe"] +{};;{} # Nullish coalescing null ?? 'hello';;'hello'