From: Igor Sysoev Date: Tue, 18 Oct 2016 12:48:13 +0000 (+0300) Subject: Fixes in generating "continue" and "break" statements. X-Git-Tag: 0.1.4~9 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=dd9a15d83050a05f530aea17c8f3ceb36782f1e2;p=njs.git Fixes in generating "continue" and "break" statements. --- diff --git a/njs/njs_generator.c b/njs/njs_generator.c index abf348ac..cee9c11e 100644 --- a/njs/njs_generator.c +++ b/njs/njs_generator.c @@ -1089,8 +1089,8 @@ found: patch = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_parser_patch_t)); if (nxt_fast_path(patch != NULL)) { - patch->next = parser->block->continuation; - parser->block->continuation = patch; + patch->next = block->continuation; + block->continuation = patch; njs_generate_code(parser, njs_vmcode_jump_t, jump); jump->code.operation = njs_vmcode_jump; @@ -1133,8 +1133,8 @@ found: patch = nxt_mem_cache_alloc(vm->mem_cache_pool, sizeof(njs_parser_patch_t)); if (nxt_fast_path(patch != NULL)) { - patch->next = parser->block->exit; - parser->block->exit = patch; + patch->next = block->exit; + block->exit = patch; njs_generate_code(parser, njs_vmcode_jump_t, jump); jump->code.operation = njs_vmcode_jump; diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 06fa9ac5..7cee5636 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -1657,6 +1657,9 @@ static njs_unit_test_t njs_test[] = "for (i in a) { if (a[i] > 4) continue; s += a[i] } s"), nxt_string("10") }, + { nxt_string("var a; for (a = 1; a; a--) switch (a) { case 0: continue }"), + nxt_string("undefined") }, + /* break. */ { nxt_string("break"),