[njs] A fix of code generation of logical operations.

Igor Sysoev igor at sysoev.ru
Fri Jul 22 12:04:49 UTC 2016


details:   http://hg.nginx.org/njs/rev/41689f60372a
branches:  
changeset: 129:41689f60372a
user:      Igor Sysoev <igor at sysoev.ru>
date:      Thu Jul 21 21:37:46 2016 +0300
description:
A fix of code generation of logical operations.

diffstat:

 njs/njs_generator.c      |  5 -----
 njs/test/njs_unit_test.c |  3 +++
 2 files changed, 3 insertions(+), 5 deletions(-)

diffs (28 lines):

diff -r f59ab0fccecb -r 41689f60372a njs/njs_generator.c
--- a/njs/njs_generator.c	Thu Jul 21 20:51:22 2016 +0300
+++ b/njs/njs_generator.c	Thu Jul 21 21:37:46 2016 +0300
@@ -1666,11 +1666,6 @@ njs_generate_test_jump_expression(njs_vm
     test_jump->code.retval = NJS_VMCODE_RETVAL;
     test_jump->value = node->left->index;
 
-    ret = njs_generator_node_index_release(vm, parser, node->left);
-    if (nxt_slow_path(ret != NXT_OK)) {
-        return ret;
-    }
-
     node->index = njs_generator_dest_index(vm, parser, node);
     if (nxt_slow_path(node->index == NJS_INDEX_ERROR)) {
         return node->index;
diff -r f59ab0fccecb -r 41689f60372a njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Thu Jul 21 20:51:22 2016 +0300
+++ b/njs/test/njs_unit_test.c	Thu Jul 21 21:37:46 2016 +0300
@@ -1476,6 +1476,9 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("var a = 3; if (true) if (false); else; a = 2; a"),
       nxt_string("2") },
 
+    { nxt_string("var a = [3], b; if (1==1||2==2) { b = '1'+'2'+a[0] }; b }"),
+      nxt_string("123") },
+
     /* do while. */
 
     { nxt_string("do { break } if (false)"),



More information about the nginx-devel mailing list