Skip to content

Commit

Permalink
JS: fix parsing of semicolon after import() CallExpression
Browse files Browse the repository at this point in the history
  • Loading branch information
tdewolff committed Jan 1, 2024
1 parent 835ff6b commit 202ca96
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions js/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func TestJS(t *testing.T) {
{"- - --3", "- - --3;"},
{"([,,])=>P", "([,,]) => { return P; };"},
{"(t)=>{//!\n}", "(t) => { //! };"},
{"import();", "import();"},
}

re := regexp.MustCompile("\n *")
Expand Down
3 changes: 3 additions & 0 deletions js/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ func (p *Parser) parseModule() (module BlockStmt) {
suffix := p.parseExpressionSuffix(left, OpExpr, OpCall)
p.exprLevel--
module.List = append(module.List, &ExprStmt{suffix})
if !p.prevLT && p.tt == SemicolonToken {
p.next()
}
} else {
importStmt := p.parseImportStmt()
module.List = append(module.List, &importStmt)
Expand Down

0 comments on commit 202ca96

Please sign in to comment.