Allow duplicate __proto__ keys in patterns, simple case (#6705)#10532
Merged
nicolo-ribaudo merged 4 commits intobabel:masterfrom Oct 14, 2019
Merged
Allow duplicate __proto__ keys in patterns, simple case (#6705)#10532nicolo-ribaudo merged 4 commits intobabel:masterfrom
nicolo-ribaudo merged 4 commits intobabel:masterfrom
Conversation
Member
|
We also need to update the test262 whitelist. Could you run |
JLHwung
approved these changes
Oct 14, 2019
Contributor
JLHwung
left a comment
There was a problem hiding this comment.
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: {} })
existentialism
approved these changes
Oct 14, 2019
Member
|
@JLHwung I have repoened the issue |
This was referenced Nov 28, 2019
This was referenced Dec 5, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thecheckPropClashfunction 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.