LibJS: Update Array.prototype.sort comments to align with implementation

This was fixed in the change-array-by-copy proposal. See:
https://github.com/tc39/proposal-change-array-by-copy/commit/60823eb
This commit is contained in:
Timothy Flynn 2022-07-27 10:57:01 -04:00 committed by Linus Groh
parent b89aced2e3
commit a8d532c4fe

View file

@ -1582,21 +1582,8 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayPrototype::sort)
// 9. Repeat, while j < itemCount,
for (; j < item_count; ++j) {
// a. Perform ? CreateDataPropertyOrThrow(obj, ! ToString(𝔽(j)), sortedList[j]).
// FIXME: Spec issue: The above step should likely be:
//
// Perform ? Set(obj, ! ToString(𝔽(j)), items[j], true).
//
// That is the behavior of SortIndexedProperties in ECMA-262, and about a dozen test262
// tests will failed if CreateDataPropertyOrThrow is used instead. For example,
// test/built-ins/Array/prototype/sort/precise-getter-appends-elements.js fails in
// CreateDataPropertyOrThrow because the Array object is configurable but the property
// created by Object.defineProperty is not.
//
// See: https://github.com/tc39/proposal-change-array-by-copy/issues/97
// a. Perform ? Set(obj, ! ToString(𝔽(j)), sortedList[j], true).
TRY(object->set(j, sorted_list[j], Object::ShouldThrowExceptions::Yes));
// b. Set j to j + 1.
}