[njs] Fixed return value on deleting non-existent property.
Valentin Bartenev
vbart at nginx.com
Mon May 6 18:25:17 UTC 2019
details: https://hg.nginx.org/njs/rev/96c78f35a809
branches:
changeset: 952:96c78f35a809
user: Valentin Bartenev <vbart at nginx.com>
date: Mon May 06 21:24:31 2019 +0300
description:
Fixed return value on deleting non-existent property.
diffstat:
njs/njs_vm.c | 9 +--------
njs/test/njs_unit_test.c | 11 ++++++++++-
2 files changed, 11 insertions(+), 9 deletions(-)
diffs (78 lines):
diff -r f876e5d1be41 -r 96c78f35a809 njs/njs_vm.c
--- a/njs/njs_vm.c Mon May 06 20:26:58 2019 +0300
+++ b/njs/njs_vm.c Mon May 06 21:24:31 2019 +0300
@@ -712,12 +712,9 @@ njs_vmcode_property_delete(njs_vm_t *vm,
njs_value_t *property)
{
njs_ret_t ret;
- const njs_value_t *retval;
njs_object_prop_t *prop;
njs_property_query_t pq;
- retval = &njs_value_false;
-
njs_property_query_init(&pq, NJS_PROPERTY_QUERY_DELETE, 1);
ret = njs_property_query(vm, &pq, object, property);
@@ -734,7 +731,6 @@ njs_vmcode_property_delete(njs_vm_t *vm,
case NJS_PROPERTY_REF:
njs_set_invalid(prop->value.data.u.value);
- retval = &njs_value_true;
goto done;
case NJS_PROPERTY_HANDLER:
@@ -744,7 +740,6 @@ njs_vmcode_property_delete(njs_vm_t *vm,
return ret;
}
- retval = &njs_value_true;
goto done;
}
@@ -768,8 +763,6 @@ njs_vmcode_property_delete(njs_vm_t *vm,
prop->type = NJS_WHITEOUT;
njs_set_invalid(&prop->value);
- retval = &njs_value_true;
-
break;
case NXT_DECLINED:
@@ -784,7 +777,7 @@ njs_vmcode_property_delete(njs_vm_t *vm,
done:
- vm->retval = *retval;
+ vm->retval = njs_value_true;
return sizeof(njs_vmcode_3addr_t);
}
diff -r f876e5d1be41 -r 96c78f35a809 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Mon May 06 20:26:58 2019 +0300
+++ b/njs/test/njs_unit_test.c Mon May 06 21:24:31 2019 +0300
@@ -3128,6 +3128,15 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("delete 1"),
nxt_string("true") },
+ { nxt_string("var a = []; delete a[1]"),
+ nxt_string("true") },
+
+ { nxt_string("var o = {}; [delete o.m, delete o.m]"),
+ nxt_string("true,true") },
+
+ { nxt_string("[delete Array.nonexistent, delete Array.Array]"),
+ nxt_string("true,true") },
+
{ nxt_string("var a; delete (a = 1); a"),
nxt_string("1") },
@@ -3261,7 +3270,7 @@ static njs_unit_test_t njs_test[] =
nxt_string("1,2,34") },
{ nxt_string("delete[]['4e9']"),
- nxt_string("false") },
+ nxt_string("true") },
{ nxt_string("var n = 1, a = [ n += 1 ]; a"),
nxt_string("2") },
More information about the nginx-devel
mailing list