[njs] Function expressions did not have prototypes.
Igor Sysoev
igor at sysoev.ru
Fri Nov 4 20:51:53 UTC 2016
details: http://hg.nginx.org/njs/rev/53d2024f6ca3
branches:
changeset: 239:53d2024f6ca3
user: Igor Sysoev <igor at sysoev.ru>
date: Fri Nov 04 23:45:35 2016 +0300
description:
Function expressions did not have prototypes.
diffstat:
njs/njs_vm.c | 1 +
njs/test/njs_unit_test.c | 11 +++++++++++
2 files changed, 12 insertions(+), 0 deletions(-)
diffs (32 lines):
diff -r 109932e1d3c8 -r 53d2024f6ca3 njs/njs_vm.c
--- a/njs/njs_vm.c Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/njs_vm.c Fri Nov 04 23:45:35 2016 +0300
@@ -414,6 +414,7 @@ njs_vmcode_function(njs_vm_t *vm, njs_va
function = nxt_mem_cache_zalloc(vm->mem_cache_pool, sizeof(njs_function_t));
if (nxt_fast_path(function != NULL)) {
+ function->object.shared_hash = vm->shared->function_prototype_hash;
function->object.__proto__ =
&vm->prototypes[NJS_PROTOTYPE_FUNCTION].object;
function->args_offset = 1;
diff -r 109932e1d3c8 -r 53d2024f6ca3 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Fri Nov 04 18:25:55 2016 +0300
+++ b/njs/test/njs_unit_test.c Fri Nov 04 23:45:35 2016 +0300
@@ -4167,6 +4167,17 @@ static njs_unit_test_t njs_test[] =
"o.constructor === F"),
nxt_string("true") },
+ { nxt_string("function F() { return }"
+ "var o = new F();"
+ "o.__proto__ === F.prototype"),
+ nxt_string("true") },
+
+ { nxt_string("function F(){}; typeof F.prototype"),
+ nxt_string("object") },
+
+ { nxt_string("var F = function (){}; typeof F.prototype"),
+ nxt_string("object") },
+
{ nxt_string("function F() { return Number }"
"var o = new (F())(5);"
"typeof o +' '+ o"),
More information about the nginx-devel
mailing list