Skip to content

Commit

Permalink
Do not auto-insert semicolon in VariableDeclarationList (#2266)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tunz committed Sep 5, 2022
1 parent 3983363 commit b63d04c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions boa_engine/src/syntax/parser/statement/variable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand Down

0 comments on commit b63d04c

Please sign in to comment.