]> git.kaiwu.me - njs.git/commitdiff
Fixed vmcode function call.
authorhongzhidao <hongzhidao@gmail.com>
Mon, 7 Jan 2019 09:40:48 +0000 (17:40 +0800)
committerhongzhidao <hongzhidao@gmail.com>
Mon, 7 Jan 2019 09:40:48 +0000 (17:40 +0800)
This closes #82 issue on Github.

njs/njs_vm.c
njs/test/njs_unit_test.c

index 4d8e46bd5c6279afed55bc24f83d988196006c53..da327e1932e926d05faa9b1b0e69bfcb4e2a1b65 100644 (file)
@@ -2086,8 +2086,14 @@ njs_vmcode_function_call(njs_vm_t *vm, njs_value_t *invld, njs_value_t *retval)
          * If a retval is in a callee arguments scope it
          * must be in the previous callee arguments scope.
          */
-        vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] =
-                              vm->top_frame->arguments + function->args_offset;
+        args = vm->top_frame->arguments;
+        function = vm->top_frame->function;
+
+        if (function != NULL) {
+            args += function->args_offset;
+        }
+
+        vm->scopes[NJS_SCOPE_CALLEE_ARGUMENTS] = args;
 
         retval = njs_vmcode_operand(vm, retval);
         /*
index fdc5aadb726bc2c6b9dbd6a8c0c23707b3700a7d..d76e85dc79409a9a4282ad5a16daa30a979d7a58 100644 (file)
@@ -4017,6 +4017,9 @@ static njs_unit_test_t  njs_test[] =
     { nxt_string("var f = ''.concat.bind(0, 1, 2, 3, 4); f(5, 6, 7, 8, 9)"),
       nxt_string("0123456789") },
 
+    { nxt_string("var f = ''.concat.bind(0, 1, 2, 3, 4); f(Math.sqrt(25))"),
+      nxt_string("012345") },
+
     { nxt_string("var f = String.prototype.concat.bind(0, 1); f(2)"),
       nxt_string("012") },