From: Dmitry Volyntsev Date: Tue, 28 Aug 2018 15:42:43 +0000 (+0300) Subject: Fixed exception handling in arguments of a function. X-Git-Tag: 0.2.4~16 X-Git-Url: http://git.kaiwu.me/postgresql/log/contrib/postgres_fdw/static/gitweb.js?a=commitdiff_plain;h=a4f58aa5798a061c55a190b110682166cef00681;p=njs.git Fixed exception handling in arguments of a function. --- diff --git a/njs/njs_function.c b/njs/njs_function.c index 4227f24d..1c31670e 100644 --- a/njs/njs_function.c +++ b/njs/njs_function.c @@ -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; diff --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 1629f9ed..4af8df96 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -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") },