Skip to content

Missing tests for ECMA-402 Array.prototype.toLocaleString #3298

Open
@gibson042

Description

@gibson042

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, behavior when that lookup does not return a method or when the method call returns undefined or null appears to not be covered by test262.

The following statement list should throw an exception:

delete Object.prototype.toLocaleString;
[{}].toLocaleString();

The following expression should evaluate to "undefined":

[{toLocaleString(){}}].toLocaleString()

The following expression should evaluate to "null":

[{toLocaleString(){return null}}].toLocaleString()

Every engine except JavaScriptCore seems to get this right, and bugs have now been reported there:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions