Skip to content

Commit 431306a

Browse files
Add tests for conditional keywords vs. reserverd keywords (#4598) (#4610)
Add a unit test to check the parser to handle correctly handling non-reserved keywords during a `let` declaration. This Pull Request fixes/closes #4598. It changes the following: - Add a unit test in core parser to check handling of non-reserved keywords in a `let` declaration. Related to #4593 introducing the change.
1 parent a981f32 commit 431306a

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • core/parser/src/parser/statement/declaration

core/parser/src/parser/statement/declaration/tests.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,30 @@ fn let_declaration_no_spaces() {
251251
);
252252
}
253253

254+
/// Checks `let` declaration with a reserved keyword as identifier.
255+
#[test]
256+
fn let_declaration_reserved_keyword_identifier() {
257+
let interner = &mut Interner::default();
258+
check_script_parser(
259+
"let of = 1;",
260+
vec![
261+
Declaration::Lexical(LexicalDeclaration::Let(
262+
vec![Variable::from_identifier(
263+
Identifier::new(
264+
interner.get_or_intern_static("of", utf16!("of")),
265+
Span::new((1, 5), (1, 7)),
266+
),
267+
Some(Literal::new(1, Span::new((1, 10), (1, 11))).into()),
268+
)]
269+
.try_into()
270+
.unwrap(),
271+
))
272+
.into(),
273+
],
274+
interner,
275+
);
276+
}
277+
254278
/// Checks empty `let` declaration parsing.
255279
#[test]
256280
fn empty_let_declaration() {

0 commit comments

Comments
 (0)