-
Notifications
You must be signed in to change notification settings - Fork 12.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
isDynamicName skips parentheses for element access
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.
- Loading branch information
Showing
4 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
8 changes: 8 additions & 0 deletions
8
tests/baselines/reference/propertyAssignmentOnParenthesizedNumber.symbols
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
=== tests/cases/conformance/salsa/bug38934.js === | ||
var x = {}; | ||
>x : Symbol(x, Decl(bug38934.js, 0, 3)) | ||
|
||
// should not crash and also should not result in a property '0' on x. | ||
x[(0)] = 1; | ||
>x : Symbol(x, Decl(bug38934.js, 0, 3)) | ||
|
14 changes: 14 additions & 0 deletions
14
tests/baselines/reference/propertyAssignmentOnParenthesizedNumber.types
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
=== tests/cases/conformance/salsa/bug38934.js === | ||
var x = {}; | ||
>x : {} | ||
>{} : {} | ||
|
||
// should not crash and also should not result in a property '0' on x. | ||
x[(0)] = 1; | ||
>x[(0)] = 1 : 1 | ||
>x[(0)] : any | ||
>x : {} | ||
>(0) : 0 | ||
>0 : 0 | ||
>1 : 1 | ||
|
8 changes: 8 additions & 0 deletions
8
tests/cases/conformance/salsa/propertyAssignmentOnParenthesizedNumber.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @noEmit: true | ||
// @Filename: bug38934.js | ||
|
||
var x = {}; | ||
// should not crash and also should not result in a property '0' on x. | ||
x[(0)] = 1; |