forked from babel/babel
-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
solution to [Bug]: Parser throws when var declaration and function de…
…claration in class static block babel#14257
- Loading branch information
1 parent
0f62c58
commit 4e95deb
Showing
13 changed files
with
150 additions
and
11 deletions.
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
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
1 change: 1 addition & 0 deletions
1
...ages/babel-parser/test/fixtures/es2015/class/static-block-var-and-func-same-name/input.js
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 @@ | ||
class X { static { var x; function x() {} } } |
70 changes: 70 additions & 0 deletions
70
...s/babel-parser/test/fixtures/es2015/class/static-block-var-and-func-same-name/output.json
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,70 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":45,"index":45}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":45,"index":45}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ClassDeclaration", | ||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":45,"index":45}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":7,"index":7},"identifierName":"X"}, | ||
"name": "X" | ||
}, | ||
"superClass": null, | ||
"body": { | ||
"type": "ClassBody", | ||
"start":8,"end":45,"loc":{"start":{"line":1,"column":8,"index":8},"end":{"line":1,"column":45,"index":45}}, | ||
"body": [ | ||
{ | ||
"type": "StaticBlock", | ||
"start":10,"end":43,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":43,"index":43}}, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":19,"end":25,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":25,"index":25}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":23,"end":24,"loc":{"start":{"line":1,"column":23,"index":23},"end":{"line":1,"column":24,"index":24}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":23,"end":24,"loc":{"start":{"line":1,"column":23,"index":23},"end":{"line":1,"column":24,"index":24},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "var" | ||
}, | ||
{ | ||
"type": "FunctionDeclaration", | ||
"start":26,"end":41,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":41,"index":41}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":35,"end":36,"loc":{"start":{"line":1,"column":35,"index":35},"end":{"line":1,"column":36,"index":36},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"generator": false, | ||
"async": false, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":39,"end":41,"loc":{"start":{"line":1,"column":39,"index":39},"end":{"line":1,"column":41,"index":41}}, | ||
"body": [], | ||
"directives": [] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-parser/test/fixtures/es2015/class/static-block/input.js
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 @@ | ||
class X { static { var x; function x() {} } } |
70 changes: 70 additions & 0 deletions
70
packages/babel-parser/test/fixtures/es2015/class/static-block/output.json
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,70 @@ | ||
{ | ||
"type": "File", | ||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":45,"index":45}}, | ||
"program": { | ||
"type": "Program", | ||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":45,"index":45}}, | ||
"sourceType": "script", | ||
"interpreter": null, | ||
"body": [ | ||
{ | ||
"type": "ClassDeclaration", | ||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":1,"column":45,"index":45}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":6,"end":7,"loc":{"start":{"line":1,"column":6,"index":6},"end":{"line":1,"column":7,"index":7},"identifierName":"X"}, | ||
"name": "X" | ||
}, | ||
"superClass": null, | ||
"body": { | ||
"type": "ClassBody", | ||
"start":8,"end":45,"loc":{"start":{"line":1,"column":8,"index":8},"end":{"line":1,"column":45,"index":45}}, | ||
"body": [ | ||
{ | ||
"type": "StaticBlock", | ||
"start":10,"end":43,"loc":{"start":{"line":1,"column":10,"index":10},"end":{"line":1,"column":43,"index":43}}, | ||
"body": [ | ||
{ | ||
"type": "VariableDeclaration", | ||
"start":19,"end":25,"loc":{"start":{"line":1,"column":19,"index":19},"end":{"line":1,"column":25,"index":25}}, | ||
"declarations": [ | ||
{ | ||
"type": "VariableDeclarator", | ||
"start":23,"end":24,"loc":{"start":{"line":1,"column":23,"index":23},"end":{"line":1,"column":24,"index":24}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":23,"end":24,"loc":{"start":{"line":1,"column":23,"index":23},"end":{"line":1,"column":24,"index":24},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"init": null | ||
} | ||
], | ||
"kind": "var" | ||
}, | ||
{ | ||
"type": "FunctionDeclaration", | ||
"start":26,"end":41,"loc":{"start":{"line":1,"column":26,"index":26},"end":{"line":1,"column":41,"index":41}}, | ||
"id": { | ||
"type": "Identifier", | ||
"start":35,"end":36,"loc":{"start":{"line":1,"column":35,"index":35},"end":{"line":1,"column":36,"index":36},"identifierName":"x"}, | ||
"name": "x" | ||
}, | ||
"generator": false, | ||
"async": false, | ||
"params": [], | ||
"body": { | ||
"type": "BlockStatement", | ||
"start":39,"end":41,"loc":{"start":{"line":1,"column":39,"index":39},"end":{"line":1,"column":41,"index":41}}, | ||
"body": [], | ||
"directives": [] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
3 changes: 0 additions & 3 deletions
3
.../babel-parser/test/fixtures/experimental/class-static-block/invalid-arguments/output.json
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
2 changes: 1 addition & 1 deletion
2
packages/babel-runtime-corejs2/helpers/esm/possibleConstructorReturn.js
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
2 changes: 1 addition & 1 deletion
2
packages/babel-runtime-corejs2/helpers/possibleConstructorReturn.js
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
2 changes: 1 addition & 1 deletion
2
packages/babel-runtime-corejs3/helpers/esm/possibleConstructorReturn.js
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
2 changes: 1 addition & 1 deletion
2
packages/babel-runtime-corejs3/helpers/possibleConstructorReturn.js
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
2 changes: 1 addition & 1 deletion
2
packages/babel-runtime/helpers/esm/possibleConstructorReturn.js
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
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