Bug 232724

Summary: Array.prototype.toLocaleString does not stringify undefined/null localization results
Product: WebKit Reporter: Richard Gibson <richard.gibson>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Richard Gibson 2021-11-04 13:24:51 PDT
The algorithm at https://tc39.es/ecma402/#sup-array.prototype.tolocalestring requires looking up a "toLocaleString" property on each non-undefined non-null element of the receiver array, invoking it as a method, and (absent an exception) passing the result through ToString. However, JSC appears to bypass ToString for undefined or null output from the toLocaleString method.

The following expression should evaluate to "undefined", but instead evaluates to "":
  [{toLocaleString(){}}].toLocaleString()

The following expression should evaluate to "null", but instead evaluates to "":
  [{toLocaleString(){return null}}].toLocaleString()

Also reported to test262 for coverage: https://github.com/tc39/test262/issues/3298
Comment 1 Radar WebKit Bug Importer 2021-11-11 12:25:22 PST
<rdar://problem/85310544>
Comment 2 Yusuke Suzuki 2022-01-03 07:19:01 PST
Will do it in bug 232723 :D

*** This bug has been marked as a duplicate of bug 232723 ***