]> git.kaiwu.me - njs.git/commitdiff
Fixed exception handling in arguments of a function.
authorDmitry Volyntsev <xeioex@nginx.com>
Tue, 28 Aug 2018 15:42:43 +0000 (18:42 +0300)
committerDmitry Volyntsev <xeioex@nginx.com>
Tue, 28 Aug 2018 15:42:43 +0000 (18:42 +0300)
njs/njs_function.c
njs/test/njs_unit_test.c

index 4227f24d9455ca5ee8c734113d28a4efcdcddbb3..1c31670e5c494e09a6a769d45fa8b8020183a185 100644 (file)
@@ -216,6 +216,7 @@ njs_function_frame(njs_vm_t *vm, njs_function_t *function,
 
     frame = (njs_frame_t *) native_frame;
     frame->local = value;
+    frame->previous_active_frame = vm->active_frame;
 
     return NXT_OK;
 }
@@ -392,7 +393,6 @@ njs_function_call(njs_vm_t *vm, njs_index_t retval, size_t advance)
         vm->scopes[NJS_SCOPE_CLOSURE + n] = &closure->u.values;
     }
 
-    frame->previous_active_frame = vm->active_frame;
     vm->active_frame = frame;
 
     return NJS_APPLIED;
index 1629f9ed76752ac95876384cb3aa5a2b2d756470..4af8df966efc73312dcdb779fd6f30cb215bf308 100644 (file)
@@ -5907,6 +5907,11 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("try {}"),
       nxt_string("SyntaxError: Missing catch or finally after try in 1") },
 
+    { nxt_string("function f(a) {return a;}; "
+                 "function thrower() {throw TypeError('Oops')}; "
+                 "f(thrower())"),
+      nxt_string("TypeError: Oops") },
+
     { nxt_string("var a = 0; try { a = 5 }"
                  "catch (e) { a = 9 } finally { a++ } a"),
       nxt_string("6") },