while (n < pos) {
if (array[n].str)
JS_FreeValue(ctx, JS_MKPTR(JS_TAG_STRING, array[n].str));
- if (array[n].pos == n) {
- JS_FreeValue(ctx, array[n].val);
- } else {
- if (JS_SetPropertyInt64(ctx, obj, n, array[n].val) < 0) {
- n++;
- goto exception;
- }
+ if (JS_SetPropertyInt64(ctx, obj, n, array[n].val) < 0) {
+ n++;
+ goto exception;
}
n++;
}
err = true;
}
assert(err && a.toString() === "1,2,3,4");
+
+ /* sort writes back every element, even those already in place */
+ assert_throws(TypeError, () => Array.prototype.sort.call("aa"));
+ assert_throws(TypeError, () => Object.freeze([1, 2]).sort());
}
function test_string()