diff --git a/js/ast_test.go b/js/ast_test.go index e8be59d..9454545 100644 --- a/js/ast_test.go +++ b/js/ast_test.go @@ -115,6 +115,8 @@ func TestJS(t *testing.T) { {"import o,{} from''", "import o, {} from '';"}, {"if(0)var s;else", "if (0) var s; else;"}, {"async\n()", "async();"}, + {"{};;", "{} ;"}, + {"{}\n;", "{} ;"}, } re := regexp.MustCompile("\n *") diff --git a/js/parse.go b/js/parse.go index 86c58a2..cd526bf 100644 --- a/js/parse.go +++ b/js/parse.go @@ -533,10 +533,11 @@ func (p *Parser) parseStmt(allowDeclaration bool) (stmt IStmt) { } stmt = &TryStmt{body, binding, catch, finally} case DebuggerToken: - p.next() stmt = &DebuggerStmt{} + p.next() case SemicolonToken, ErrorToken: stmt = &EmptyStmt{} + p.next() case CommentToken, CommentLineTerminatorToken: // bang comment stmt = &Comment{p.data} @@ -581,7 +582,7 @@ func (p *Parser) parseStmt(allowDeclaration bool) (stmt IStmt) { } } } - if p.tt == SemicolonToken { + if !p.prevLT && p.tt == SemicolonToken { p.next() } p.stmtLevel--