Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,12 @@ func TestParser(t *testing.T) {
`, nil)
is(len(program.Body), 1)

test("function f() { if (true) { return class A {} } let A; if (true) { A = class A {} } }", nil)
test("function f() { if (true) return class A {} }", nil)
test("function f() { let A; if (true) A = class A {} }", nil)
test("function f() { if (false) {} else return class A {} }", nil)
test("function f() { let A; if (false) {} else A = class A {} }", nil)

{
program := test(`(-2)**53`, nil)
st := program.Body[0].(*ast.ExpressionStatement).Expression.(*ast.BinaryExpression)
Expand Down
2 changes: 1 addition & 1 deletion parser/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ func (self *_parser) parseArrowFunctionBody(async bool) (ast.ConciseBody, []*ast
}

func (self *_parser) parseClass(declaration bool) *ast.ClassLiteral {
if !self.scope.allowLet && self.token == token.CLASS {
if declaration && !self.scope.allowLet && self.token == token.CLASS {
self.errorUnexpectedToken(token.CLASS)
}

Expand Down
Loading