Bug 236541 - `Array#{ groupBy, groupByToMap }` should throw a `TypeError` when `this` is `null` or `undefined`
Summary: `Array#{ groupBy, groupByToMap }` should throw a `TypeError` when `this` is `...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Yusuke Suzuki
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2022-02-12 10:07 PST by zloirock
Modified: 2022-02-14 16:16 PST (History)
10 users (show)

See Also:


Attachments
Patch (3.92 KB, patch)
2022-02-14 09:42 PST, Yusuke Suzuki
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description zloirock 2022-02-12 10:07:56 PST
(tested in playwright)

Array.prototype.groupBy.call(null, () => { /* empty */ }) // should be a TypeError
Array.prototype.groupByToMap.call(null, () => { /* empty */ }) // should be a TypeError
Comment 1 Alexey Shvayka 2022-02-14 09:31:55 PST
(In reply to zloirock from comment #0)
> (tested in playwright)
> 
> Array.prototype.groupBy.call(null, () => { /* empty */ }) // should be a
> TypeError
> Array.prototype.groupByToMap.call(null, () => { /* empty */ }) // should be
> a TypeError

Wow, that's a nice catch, thank you.
We've missed "use strict".
Comment 2 Yusuke Suzuki 2022-02-14 09:42:33 PST
Created attachment 451916 [details]
Patch
Comment 3 Alexey Shvayka 2022-02-14 09:45:08 PST
Comment on attachment 451916 [details]
Patch

I wish we could mandate "use strict" for built-ins with exception of Reflect.has, which we need to be sloppy mode JS built-in for inlining + caching.
Comment 4 EWS 2022-02-14 16:15:42 PST
Committed r289780 (247248@main): <https://commits.webkit.org/247248@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 451916 [details].
Comment 5 Radar WebKit Bug Importer 2022-02-14 16:16:18 PST
<rdar://problem/88934440>