Large literals switch to slow arrays above the fast-array capacity limit, but
the previous initialization path left their indexed values unset. Initialize
slow arrays directly so literals above 32760 elements preserve their contents.
index = (uint32_t) num;
array = value->data.u.array;
+ if (njs_slow_path(!array->object.fast_array)) {
+ prop = njs_object_property_add(vm, value, njs_number_atom(index),
+ 0);
+ if (njs_slow_path(prop == NULL)) {
+ return NJS_ERROR;
+ }
+
+ njs_value_assign(njs_prop_value(prop), init);
+ break;
+ }
+
if (index >= array->length) {
size = index - array->length;
{ njs_str("[1,2].length"),
njs_str("2") },
+ { njs_str("var src = 'return [' + '1,'.repeat(32760) + '1]';"
+ "var a = Function(src)();"
+ "[a.length, a[0], a[32760], Object.keys(a).length]"),
+ njs_str("32761,1,1,32761") },
+
{ njs_str("var a = [1,2]; a.length"),
njs_str("2") },