found:
- cons = njs_property_constructor_create(vm, &prototype->object.hash,
- &vm->scopes[NJS_SCOPE_GLOBAL][index]);
+ if (setval == NULL) {
+ setval = &vm->scopes[NJS_SCOPE_GLOBAL][index];
+ }
+
+ cons = njs_property_constructor_create(vm, &prototype->object.hash, setval);
if (nxt_fast_path(cons != NULL)) {
*retval = *cons;
return NXT_OK;
lhq.value = prop;
lhq.key_hash = NJS_CONSTRUCTOR_HASH;
lhq.key = nxt_string_value("constructor");
- lhq.replace = 0;
+ lhq.replace = 1;
lhq.pool = vm->mem_pool;
lhq.proto = &njs_object_hash_proto;
return &prop->value;
}
- njs_internal_error(vm, "lvlhsh insert failed");
+ njs_internal_error(vm, "lvlhsh insert/replace failed");
return NULL;
}
{ nxt_string("Boolean.prototype.constructor === Boolean"),
nxt_string("true") },
+ { nxt_string("Boolean.prototype.constructor = 1;"
+ "Boolean.prototype.constructor"),
+ nxt_string("1") },
+
+ { nxt_string("var c = Boolean.prototype.constructor;"
+ "Boolean.prototype.constructor = 1;"
+ "[c(0), Boolean.prototype.constructor]"),
+ nxt_string("false,1") },
+
{ nxt_string("Boolean.prototype.hasOwnProperty('constructor')"),
nxt_string("true") },