@@ -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,
@@ -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;