From dc5a75a7ace93c159290e193d01f1aa88feb2224 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 10 Jan 2012 16:10:29 +0100 Subject: [PATCH] jscript: Fixed continue inside for..in statement. --- dlls/jscript/compile.c | 9 +++------ dlls/jscript/tests/lang.js | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/dlls/jscript/compile.c b/dlls/jscript/compile.c index 4cdd2edd472..19fd0c2e0a5 100644 --- a/dlls/jscript/compile.c +++ b/dlls/jscript/compile.c @@ -1237,18 +1237,15 @@ static HRESULT compile_forin_statement(compiler_ctx_t *ctx, forin_statement_t *s static HRESULT pop_to_stat(compiler_ctx_t *ctx, statement_ctx_t *stat_ctx) { - statement_ctx_t *iter = ctx->stat_ctx; unsigned stack_pop = 0; + statement_ctx_t *iter; - while(iter) { + for(iter = ctx->stat_ctx; iter != stat_ctx; iter = iter->next) { if(iter->using_scope && !push_instr(ctx, OP_pop_scope)) return E_OUTOFMEMORY; if(iter->using_except && !push_instr(ctx, OP_pop_except)) return E_OUTOFMEMORY; stack_pop += iter->stack_use; - if(iter == stat_ctx) - break; - iter = iter->next; } /* FIXME: optimize */ @@ -1308,7 +1305,7 @@ static HRESULT compile_break_statement(compiler_ctx_t *ctx, branch_statement_t * if(stat->identifier) return push_instr(ctx, OP_label) ? S_OK : E_OUTOFMEMORY; /* FIXME */ - hres = pop_to_stat(ctx, pop_ctx); + hres = pop_to_stat(ctx, pop_ctx->next); if(FAILED(hres)) return hres; diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index d7182c6c197..58d459971c9 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -839,8 +839,8 @@ for(tmp in obj1.nonexistent) ok(false, "for(tmp in obj1.nonexistent) called with tmp = " + tmp); ok(!("nonexistent" in obj1), "nonexistent added to obj1 by for..in loop"); -var i, j; +var i, j; tmp = ""; i = 0; @@ -896,6 +896,26 @@ for(j in [1,2,3]) { } ok(tmp === "1234", "tmp = " + tmp); +tmp = 0; +for(var iter in [1,2,3]) { + tmp += +iter; + continue; +} +ok(tmp === 3, "tmp = " + tmp); + +tmp = false; +for(var iter in [1,2,3]) { + switch(+iter) { + case 1: + tmp = true; + try { + continue; + }finally {} + default: + continue; + } +} +ok(tmp, "tmp = " + tmp); ok((void 1) === undefined, "(void 1) !== undefined");