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

Name mangling rules allow creating JS objects with duplicate properties #4520

Closed
yawaramin opened this issue Jul 11, 2020 · 1 comment
Closed
Labels
stale Old issues that went stale

Comments

@yawaramin
Copy link
Contributor

According to the name mangling rules in #999, the following are valid in BuckleScript:

let a = [%bs.obj { x__int = 1; x__float = 1. }]
let b = [%bs.obj { x = 1; x__ = 1. }]

However they output JS output objects with duplicate properties:

var a = { x: 1, x: 1 };
var b = { x: 1, x: 1 };

However note that duplicate properties are not necessarily an error in JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#Duplicate_property_names

In ECMAScript 5 strict mode code, duplicate property names were considered a SyntaxError. With the introduction of computed property names making duplication possible at runtime, ECMAScript 2015 has removed this restriction.

@stale
Copy link

stale bot commented Jul 1, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Old issues that went stale label Jul 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale Old issues that went stale
Projects
None yet
Development

No branches or pull requests

1 participant