From b18f060a3fed429a60502ea807a40d65fd60c7e5 Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Sat, 3 Jun 2023 01:50:03 -0600 Subject: [PATCH 1/2] Allow `true`, `false` and `null` in object patterns --- boa_parser/src/parser/statement/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/boa_parser/src/parser/statement/mod.rs b/boa_parser/src/parser/statement/mod.rs index d55d85da6a0..b791a954296 100644 --- a/boa_parser/src/parser/statement/mod.rs +++ b/boa_parser/src/parser/statement/mod.rs @@ -529,6 +529,8 @@ where | TokenKind::NumericLiteral(_) => true, TokenKind::IdentifierName(_) if next_token_is_colon => true, TokenKind::Keyword(_) if next_token_is_colon => true, + TokenKind::BooleanLiteral(_) if next_token_is_colon => true, + TokenKind::NullLiteral(_) if next_token_is_colon => true, _ => false, }; From cd1ef41e367f768e4320ce07bfcc71db1dd90050 Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Sat, 3 Jun 2023 13:42:26 -0600 Subject: [PATCH 2/2] Add test --- boa_engine/src/tests/mod.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/boa_engine/src/tests/mod.rs b/boa_engine/src/tests/mod.rs index f9261ba4b48..dc4941ea7a5 100644 --- a/boa_engine/src/tests/mod.rs +++ b/boa_engine/src/tests/mod.rs @@ -481,3 +481,21 @@ fn template_literal() { "result: 10 and 20", )]); } + +#[test] +fn null_bool_in_object_pattern() { + run_test_actions([ + TestAction::run(indoc! {r#" + let obj = { + null: 0, + true: 10, + false: 100 + }; + + let { null: a, true: b, false: c } = obj; + "#}), + TestAction::assert_eq("a", 0), + TestAction::assert_eq("b", 10), + TestAction::assert_eq("c", 100), + ]); +}