Welcome! Log In Create A New Profile

Advanced

[njs] Fixed type of iteration variable in for-in with array values.

Dmitry Volyntsev
December 04, 2018 01:14PM
details: https://hg.nginx.org/njs/rev/1dbef01a6d6c
branches:
changeset: 684:1dbef01a6d6c
user: Dmitry Volyntsev <xeioex@nginx.com>
date: Tue Dec 04 21:13:13 2018 +0300
description:
Fixed type of iteration variable in for-in with array values.

diffstat:

njs/njs_vm.c | 2 +-
njs/test/njs_unit_test.c | 3 +++
2 files changed, 4 insertions(+), 1 deletions(-)

diffs (25 lines):

diff -r ce3a943df9c4 -r 1dbef01a6d6c njs/njs_vm.c
--- a/njs/njs_vm.c Mon Dec 03 19:23:27 2018 +0300
+++ b/njs/njs_vm.c Tue Dec 04 21:13:13 2018 +0300
@@ -829,7 +829,7 @@ njs_vmcode_property_next(njs_vm_t *vm, n
n = next->index++;

if (njs_is_valid(&array->start[n])) {
- njs_value_number_set(retval, n);
+ njs_uint32_to_string(retval, n);

return code->offset;
}
diff -r ce3a943df9c4 -r 1dbef01a6d6c njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Mon Dec 03 19:23:27 2018 +0300
+++ b/njs/test/njs_unit_test.c Tue Dec 04 21:13:13 2018 +0300
@@ -2244,6 +2244,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("var s = ''; for (var p in [1,2]) {s += p}; s"),
nxt_string("01") },

+ { nxt_string("var s; for (var p in [1]) {s = typeof(p)}; s"),
+ nxt_string("string") },
+
{ nxt_string("var s = ''; for (var p in {a:1, b:2}) {s += p}; s"),
nxt_string("ab") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed type of iteration variable in for-in with array values.

Dmitry Volyntsev 50 December 04, 2018 01:14PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 69
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready