Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JS] Behaviour of Array.prototype.join() incompatible with ECMAScript v6.0 #335

Open
patrik-simunic-cz opened this issue Nov 12, 2023 · 0 comments
Labels
pending triage Pending further investigation

Comments

@patrik-simunic-cz
Copy link

patrik-simunic-cz commented Nov 12, 2023

Issue description

The implementation of method Array.prototype.join() diverts from the official ECMAScript (ES) version 6.0 documentation. ECMAScript treats undefined and null elements as empty strings, while this custom proprietary runtime first converts them to null, then converts null to string and only then treats these double converted strings as elements:

// ECMAScript v6.0
var officialA = ["foo", undefined].join("/"); // -> "foo/"
var officialB = ["foo", null].join("/"); // -> "foo/"

// AppSync
var customA = ["foo", undefined].join("/"); // -> "foo/null"
var customB = ["foo", null].join("/"); // -> "foo/null"

Read the relevant section here - https://262.ecma-international.org/6.0/#sec-array.prototype.join
- under the procedure step 13.c you'll find stated:

If element is undefined or null, let next be the empty String; otherwise, let next be ToString(element).

Bug reproduction

See the reproducible bug demo here: https://github.com/testuj-to/appsync-esv6-incompatible-join
In the demo, 2 strings are expected to be returned ("foo/" and "foo/"), instead this is the output:
Screenshot 2023-11-12 at 2 09 28

@onlybakam onlybakam added the pending triage Pending further investigation label Dec 11, 2023
@patrik-simunic-cz patrik-simunic-cz changed the title Behaviour of Array.prototype.join() incompatible with ECMAScript v6.0 [JS] Behaviour of Array.prototype.join() incompatible with ECMAScript v6.0 Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending triage Pending further investigation
Projects
None yet
Development

No branches or pull requests

2 participants