Browse Source

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
pull/2268/head
Choongwoo Han 2 years ago
parent
commit
b63d04c48b
  1. 15
      boa_engine/src/syntax/parser/statement/variable/mod.rs

15
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;
}
}

Loading…
Cancel
Save