Ignore:
Timestamp:
Feb 14, 2022, 4:14:28 PM (3 years ago)
Author:
[email protected]
Message:

Array#{ groupBy, groupByToMap } should throw a TypeError when this is null or undefined
https://bugs.webkit.org/show_bug.cgi?id=236541

Reviewed by Alexey Shvayka.

JSTests:

  • stress/array-group-by-null-or-undefined.js: Added.

(shouldThrow):

Source/JavaScriptCore:

While we are correctly using @toObject, these functions missed "use strict", which enforces a function
to change a non object |this| to an object (in this case, global object). This patch adds "use strict",
to make these function strict code.

  • builtins/ArrayPrototype.js:

(groupBy):
(groupByToMap):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/builtins/ArrayPrototype.js

    r287136 r289780  
    159159function groupBy(callback /*, thisArg */)
    160160{
     161    "use strict";
     162
    161163    var array = @toObject(this, "Array.prototype.groupBy requires that |this| not be null or undefined");
    162164    var length = @toLength(array.length);
     
    183185function groupByToMap(callback /*, thisArg */)
    184186{
     187    "use strict";
     188
    185189    var array = @toObject(this, "Array.prototype.groupByToMap requires that |this| not be null or undefined");
    186190    var length = @toLength(array.length);
Note: See TracChangeset for help on using the changeset viewer.