浏览代码

LibJS: Update order of steps in CanonicalNumericIndexString

This is an editorial change in the ECMA-262 spec.

See: https://github.com/tc39/ecma262/commit/be5db32
Linus Groh 3 年之前
父节点
当前提交
8b035b80d3
共有 1 个文件被更改,包括 5 次插入5 次删除
  1. 5 5
      Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp

+ 5 - 5
Userland/Libraries/LibJS/Runtime/AbstractOperations.cpp

@@ -1178,12 +1178,12 @@ CanonicalIndex canonical_numeric_index_string(PropertyKey const& property_key, C
     if (endptr != argument.characters() + argument.length())
         return CanonicalIndex(CanonicalIndex::Type::Undefined, 0);
 
-    // 3. If SameValue(! ToString(n), argument) is false, return undefined.
-    if (n.to_string_without_side_effects() != argument)
-        return CanonicalIndex(CanonicalIndex::Type::Undefined, 0);
+    // 3. If SameValue(! ToString(n), argument) is true, return n.
+    if (n.to_string_without_side_effects() == argument)
+        return CanonicalIndex(CanonicalIndex::Type::Numeric, 0);
 
-    // 4. Return n.
-    return CanonicalIndex(CanonicalIndex::Type::Numeric, 0);
+    // 4. Return undefined.
+    return CanonicalIndex(CanonicalIndex::Type::Undefined, 0);
 }
 
 // 22.1.3.17.1 GetSubstitution ( matched, str, position, captures, namedCaptures, replacement ), https://tc39.es/ecma262/#sec-getsubstitution