[njs] A fix of var declaration.

Igor Sysoev igor at sysoev.ru
Mon Oct 17 14:01:41 UTC 2016


details:   http://hg.nginx.org/njs/rev/5d08fa7106b8
branches:  
changeset: 200:5d08fa7106b8
user:      Igor Sysoev <igor at sysoev.ru>
date:      Fri Oct 14 18:12:36 2016 +0300
description:
A fix of var declaration.

diffstat:

 njs/njs_parser.c         |  1 +
 njs/test/njs_unit_test.c |  6 ++++++
 2 files changed, 7 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r c68db870b8b0 -r 5d08fa7106b8 njs/njs_parser.c
--- a/njs/njs_parser.c	Fri Oct 14 17:21:35 2016 +0300
+++ b/njs/njs_parser.c	Fri Oct 14 18:12:36 2016 +0300
@@ -641,6 +641,7 @@ njs_parser_var_statement(njs_vm_t *vm, n
     njs_variable_t     *var;
     njs_parser_node_t  *left, *stmt, *name, *assign;
 
+    parser->node = NULL;
     left = NULL;
 
     do {
diff -r c68db870b8b0 -r 5d08fa7106b8 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c	Fri Oct 14 17:21:35 2016 +0300
+++ b/njs/test/njs_unit_test.c	Fri Oct 14 18:12:36 2016 +0300
@@ -68,6 +68,12 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("var a = 1; var b; a"),
       nxt_string("1") },
 
+    { nxt_string("a = 1;for(;a;a--)var a; a"),
+      nxt_string("0") },
+
+    { nxt_string("if(1)if(0){0?0:0}else\nvar a\nelse\nvar b"),
+      nxt_string("undefined") },
+
     { nxt_string("function f(){} function f(){}"),
       nxt_string("SyntaxError: Duplicate declaration \"f\" in 1") },
 



More information about the nginx-devel mailing list