Mercurial > njs
changeset 684:1dbef01a6d6c
Fixed type of iteration variable in for-in with array values.
| author | Dmitry Volyntsev <xeioex@nginx.com> |
|---|---|
| date | Tue, 04 Dec 2018 21:13:13 +0300 |
| parents | ce3a943df9c4 |
| children | 23fecf3fcc60 |
| files | njs/njs_vm.c njs/test/njs_unit_test.c |
| diffstat | 2 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ 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; }
--- 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 @@ { 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") },
