Skip to content

Commit

Permalink
Applied fix for dop251#148 to for-of loops.
Browse files Browse the repository at this point in the history
  • Loading branch information
dop251 committed Apr 14, 2020
1 parent 00c4500 commit 3347463
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler_stmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (c *compiler) compileForOfStatement(v *ast.ForOfStatement, needResult bool)

func (c *compiler) compileLabeledForOfStatement(v *ast.ForOfStatement, needResult bool, label unistring.String) {
c.block = &block{
typ: blockLoop,
typ: blockLoopEnum,
outer: c.block,
label: label,
needResult: needResult,
Expand Down
11 changes: 11 additions & 0 deletions compiler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,17 @@ func TestReturnFromForInLoop(t *testing.T) {
testScript1(SCRIPT, valueTrue, t)
}

func TestReturnFromForOfLoop(t *testing.T) {
const SCRIPT = `
(function f() {
for (var i of [1]) {
return true;
}
})();
`
testScript1(SCRIPT, valueTrue, t)
}

func TestIfStackLeaks(t *testing.T) {
const SCRIPT = `
var t = 0;
Expand Down

0 comments on commit 3347463

Please sign in to comment.