[webkit-changes] [WebKit/WebKit] 5209f3: [JSC] `Object.groupBy` and `Map.groupBy` should al...

SUZUKI Sosuke noreply at github.com
Wed Mar 27 07:38:04 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5209f3cb6908f44c6035c69004bd7c8dc1044f7f
      https://github.com/WebKit/WebKit/commit/5209f3cb6908f44c6035c69004bd7c8dc1044f7f
  Author: Sosuke Suzuki <sosuke.suzuki at dr-ubie.com>
  Date:   2024-03-27 (Wed, 27 Mar 2024)

  Changed paths:
    M JSTests/stress/map-groupBy.js
    M JSTests/stress/object-groupBy.js
    M Source/JavaScriptCore/builtins/MapConstructor.js
    M Source/JavaScriptCore/builtins/ObjectConstructor.js

  Log Message:
  -----------
  [JSC] `Object.groupBy` and `Map.groupBy` should allow iterable `items` that are not objects
https://bugs.webkit.org/show_bug.cgi?id=271524

Reviewed by Keith Miller.

Before this change, Object.groupBy and Map.groupBy would throw a TypeError if items were not objects.
Therefore, they would throw a TypeError even when passed primitive values with @@iterator, such as strings. This is incorrect behavior.
In this patch, following the specification[1], Object.groupBy and Map.groupBy are changed to throw a TypeError only when the first argument, items, is null or undefined.
Even after this change, according to the specification[2], they will throw a TypeError for primitives like Number or Symbol that do not have @@iterator.

[1]: https://tc39.es/ecma262/#sec-groupby
[2]: https://tc39.es/ecma262/#sec-getiterator

* JSTests/stress/map-groupBy.js:
(catch):
* JSTests/stress/object-groupBy.js:
(catch):
* Source/JavaScriptCore/builtins/MapConstructor.js:
(wrapper.iterator):
(groupBy):
* Source/JavaScriptCore/builtins/ObjectConstructor.js:
(wrapper.iterator):
(groupBy):

Canonical link: https://commits.webkit.org/276736@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list