Skip to content

Conversation

@sandersn
Copy link
Member

@sandersnsandersn 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.

@microsoftmicrosoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

x[(0)] = 1 asserts with 'Invalid cast. The supplied value [object Object] did not pass the test 'isBindableStaticAccessExpression'.

5 participants

@sandersn@RyanCavanaugh@typescript-bot@andrewbranch