From a8d532c4fe85dff4f783acf4549ac41ef4fcdf1d Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 27 Jul 2022 10:57:01 -0400 Subject: [PATCH] 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 --- .../Libraries/LibJS/Runtime/ArrayPrototype.cpp | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp index dc961d4b8b..47cfd75cc9 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayPrototype.cpp @@ -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. }