Skip to content

isDynamicName skips parentheses for element access #39025

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

Merged
merged 1 commit into from
Jun 11, 2020

Conversation

sandersn
Copy link
Member

@sandersn sandersn commented Jun 11, 2020

Neither x[0] nor x[(0)] should be dynamic names. Previously, the latter was because isDynamicName didn't skip parentheses.

Since the binder treats dynamic names in property assignments as assignment declarations, this incorrectly tried to create a binding for expressions like x[(0)] = 1.

This caused an assert because x[(0)] would not take the dynamic name code path during binding (hasDynamicName returned false), but the normal code path for static names.

Fixes #38934

Neither `x[0]` nor `x[(0)]` should be dynamic names. Previously, the
latter was because `isDynamicName` didn't skip parentheses.

Since the binder treats dynamic names in property assignments as
assignment declarations, this incorrectly tried to create a binding for
expressions like `x[(0)] = 1`.

This caused an assert because `x[(0)]` would not take the dynamic name
code path during binding (`hasDynamicName` returned false), but the
normal code path for static names.
@RyanCavanaugh
Copy link
Member

@typescript-bot cherry-pick this to release-3.9

@typescript-bot
Copy link
Collaborator

typescript-bot commented Jun 22, 2020

Heya @RyanCavanaugh, I've started to run the task to cherry-pick this into release-3.9 on this PR at a64166d. You can monitor the build here.

@typescript-bot
Copy link
Collaborator

Hey @RyanCavanaugh, I couldn't open a PR with the cherry-pick. (You can check the log here). You may need to squash and pick this PR into release-3.9 manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants