From: Dmitry Volyntsev Date: Tue, 4 Dec 2018 18:13:13 +0000 (+0300) Subject: Fixed type of iteration variable in for-in with array values. X-Git-Tag: 0.2.7~9 X-Git-Url: http://www.kaiwu.me/postgresql/commit/?a=commitdiff_plain;h=ad04d7170a42326660b44c57d0612ba652f8899f;p=njs.git Fixed type of iteration variable in for-in with array values. --- diff --git a/njs/njs_vm.c b/njs/njs_vm.c index 56737b4c..05c13b11 100644 --- a/njs/njs_vm.c +++ b/njs/njs_vm.c @@ -829,7 +829,7 @@ njs_vmcode_property_next(njs_vm_t *vm, njs_value_t *object, njs_value_t *value) 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 --git a/njs/test/njs_unit_test.c b/njs/test/njs_unit_test.c index 3f84c3b5..4953df58 100644 --- a/njs/test/njs_unit_test.c +++ b/njs/test/njs_unit_test.c @@ -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") },