]> git.kaiwu.me - njs.git/commitdiff
Fixes in generating "continue" and "break" statements.
authorIgor Sysoev <igor@sysoev.ru>
Tue, 18 Oct 2016 12:48:13 +0000 (15:48 +0300)
committerIgor Sysoev <igor@sysoev.ru>
Tue, 18 Oct 2016 12:48:13 +0000 (15:48 +0300)
njs/njs_generator.c
njs/test/njs_unit_test.c

index abf348acff10982c43c48dbf9ad6b55754a986f9..cee9c11e4c0d49dd956714fcb0298f598753570f 100644 (file)
@@ -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;
index 06fa9ac532cc930294c725b68c94e2a1a1141d1c..7cee5636450fb2caab9f97f080ff5a33e51385e2 100644 (file)
@@ -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"),