Skip to content

Commit

Permalink
Make sure case statements are not treated as a single-statement conte…
Browse files Browse the repository at this point in the history
…xt. Fixes #456.
  • Loading branch information
dop251 committed Nov 18, 2022
1 parent 6c0d988 commit d4bf6fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5601,6 +5601,18 @@ func TestForInLoopContinueOuter(t *testing.T) {
testScript(SCRIPT, _undefined, t)
}

func TestLexicalDeclInSwitch(t *testing.T) {
const SCRIPT = `
switch(0) {
case 1:
if (false) b = 3;
case 2:
const c = 1;
}
`
testScript(SCRIPT, _undefined, t)
}

/*
func TestBabel(t *testing.T) {
src, err := os.ReadFile("babel7.js")
Expand Down
1 change: 1 addition & 0 deletions parser/statement.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ func (self *_parser) parseCaseStatement() *ast.CaseStatement {
self.token == token.DEFAULT {
break
}
self.scope.allowLet = true
node.Consequent = append(node.Consequent, self.parseStatement())

}
Expand Down

0 comments on commit d4bf6fd

Please sign in to comment.