Skip to content

Commit

Permalink
Merge branch 'master' into fix-issue-755
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimZhestikov authored Jul 10, 2024
2 parents 662be21 + b593dd4 commit 194112d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/njs_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -1054,9 +1054,11 @@ njs_function_constructor(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,

njs_chb_append_literal(&chain, "){");

ret = njs_value_to_chain(vm, &chain, njs_argument(args, nargs - 1));
if (njs_slow_path(ret < NJS_OK)) {
return ret;
if (nargs > 1) {
ret = njs_value_to_chain(vm, &chain, njs_argument(args, nargs - 1));
if (njs_slow_path(ret < NJS_OK)) {
return ret;
}
}

njs_chb_append_literal(&chain, "})");
Expand Down
3 changes: 3 additions & 0 deletions src/test/njs_unit_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -14163,6 +14163,9 @@ static njs_unit_test_t njs_test[] =
{ njs_str("Function.constructor === Function"),
njs_str("true") },

{ njs_str("Function.constructor()"),
njs_str("[object Function]") },

{ njs_str("function f() {} f.__proto__ === Function.prototype"),
njs_str("true") },

Expand Down

0 comments on commit 194112d

Please sign in to comment.