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
Allow duplicate __proto__ keys in patterns, simple case (#6705) #10532
Conversation
We also need to update the test262 whitelist. Could you run |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this PR we have fixed the simple case of #6705, I suggest we submit a new issue to cover the following cases:
// argument destructuring
({ __proto__: x, __proto__: y }) => {}
// forX destructuring
for ({ __proto__: x, __proto__: y } of []);
// nested destructuring
({ a: { __proto__: x, __proto__: y } } = { a: {} })
@JLHwung I have repoened the issue |
This is a fix for an error being thrown when there is a duplicate
__proto__
in a destructuring pattern. It only fixes the simple case when the pattern is immediately followed by a=
. I renamed thecheckPropClash
function tocheckDuplicatedProto
, as advised in the issue. Instead of relying exclusively on a boolean flag to determine whether__proto__
had appeared before or not, I store the amount of times it has appeared and the position of the first duplicated occurrence. InparseObj
, I check for the existence of the first duplicated occurrence property I stored before and raise an error if it's there and the next token is not a=
.Please let me know if there are any concerns or improvements I can make. I'm thinking about the more complicated case as well but I'll need a little more time with the code before I can tackle it.
Thanks @nicolo-ribaudo for the hints on how to get started.