From b63d04c48b5dcc2f0df1a2dadc15d42f59406ace Mon Sep 17 00:00:00 2001 From: Choongwoo Han Date: Mon, 5 Sep 2022 20:06:42 +0000 Subject: [PATCH] Do not auto-insert semicolon in VariableDeclarationList (#2266) There can be a line terminator in the middle of variable declaration statement. For example, ```js var a , b; ``` In this case, we should not insert semicolon automatically. This fixes: - test262/test/language/asi/S7.9_A7_T8.js - test262/test/language/asi/S7.9_A7_T9.js --- .../src/syntax/parser/statement/variable/mod.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/boa_engine/src/syntax/parser/statement/variable/mod.rs b/boa_engine/src/syntax/parser/statement/variable/mod.rs index 3f8b72f4ff4..b94acf33a0b 100644 --- a/boa_engine/src/syntax/parser/statement/variable/mod.rs +++ b/boa_engine/src/syntax/parser/statement/variable/mod.rs @@ -8,10 +8,8 @@ use crate::syntax::{ lexer::TokenKind, parser::statement::{ArrayBindingPattern, ObjectBindingPattern}, parser::{ - cursor::{Cursor, SemicolonResult}, - expression::Initializer, - statement::BindingIdentifier, - AllowAwait, AllowIn, AllowYield, ParseError, TokenParser, + cursor::Cursor, expression::Initializer, statement::BindingIdentifier, AllowAwait, AllowIn, + AllowYield, ParseError, TokenParser, }, }; use boa_interner::Interner; @@ -125,13 +123,8 @@ where .parse(cursor, interner)?, ); - match cursor.peek_semicolon(interner)? { - SemicolonResult::NotFound(tk) - if tk.kind() == &TokenKind::Punctuator(Punctuator::Comma) => - { - let _next = cursor.next(interner).expect("token disappeared"); - } - _ => break, + if cursor.next_if(Punctuator::Comma, interner)?.is_none() { + break; } }