diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 0e83b088cc..f47b80448b 100644 --- a/packages/babel-parser/src/parser/statement.js +++ b/packages/babel-parser/src/parser/statement.js @@ -22,10 +22,6 @@ import { SCOPE_SUPER, } from "../util/scopeflags"; -// Reused empty array added for node fields that are always empty. - -const empty = []; - const loopLabel = { kind: "loop" }, switchLabel = { kind: "switch" }; @@ -683,7 +679,6 @@ export default class StatementParser extends ExpressionParser { node.handler = this.finishNode(clause, "CatchClause"); } - node.guardedHandlers = empty; node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null; if (!node.handler && !node.finalizer) { diff --git a/packages/babel-parser/src/types.js b/packages/babel-parser/src/types.js index 22ceb9e2df..2c5992d2ba 100644 --- a/packages/babel-parser/src/types.js +++ b/packages/babel-parser/src/types.js @@ -263,8 +263,6 @@ export type TryStatement = NodeBase & { block: BlockStatement, handler: CatchClause | null, finalizer: BlockStatement | null, - - guardedHandlers: $ReadOnlyArray, // TODO: Not in spec }; export type CatchClause = NodeBase & { diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json index b576780b70..a465e0c09f 100644 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-hang-func/output.json @@ -198,7 +198,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json index 677fad5fcd..8c0ce7e4c0 100644 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-let-outside/output.json @@ -109,7 +109,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null }, { diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json index 6b4c229346..1baae9250d 100644 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-nested/output.json @@ -238,14 +238,12 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json index 439f7f105f..f9626718bb 100644 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var-outside/output.json @@ -109,7 +109,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null }, { diff --git a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json index 66d668784c..54bc80b806 100644 --- a/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json +++ b/packages/babel-parser/test/fixtures/core/scope/dupl-bind-catch-var/output.json @@ -161,7 +161,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/276/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/276/output.json index d363a5d4cc..7124a7ba6f 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/276/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/276/output.json @@ -109,7 +109,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/277/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/277/output.json index 80dde4eca4..0f104da5ae 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/277/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/277/output.json @@ -109,7 +109,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/278/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/278/output.json index 4b11f881de..8721f9d984 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/278/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/278/output.json @@ -109,7 +109,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/279/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/279/output.json index fbcb70be26..49094bb0e6 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/279/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/279/output.json @@ -176,7 +176,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/280/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/280/output.json index ea48a40300..b1589f69dc 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/280/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/280/output.json @@ -61,7 +61,6 @@ "directives": [] }, "handler": null, - "guardedHandlers": [], "finalizer": { "type": "BlockStatement", "start": 16, diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/281/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/281/output.json index bc19c5698f..7bb5acfbed 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/281/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/281/output.json @@ -225,7 +225,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/core/uncategorised/282/output.json b/packages/babel-parser/test/fixtures/core/uncategorised/282/output.json index dc667d97ef..91b0085400 100644 --- a/packages/babel-parser/test/fixtures/core/uncategorised/282/output.json +++ b/packages/babel-parser/test/fixtures/core/uncategorised/282/output.json @@ -225,7 +225,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": { "type": "BlockStatement", "start": 47, diff --git a/packages/babel-parser/test/fixtures/es2015/uncategorised/313/output.json b/packages/babel-parser/test/fixtures/es2015/uncategorised/313/output.json index a66c95114f..1714f8b7d8 100644 --- a/packages/babel-parser/test/fixtures/es2015/uncategorised/313/output.json +++ b/packages/babel-parser/test/fixtures/es2015/uncategorised/313/output.json @@ -164,7 +164,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/es2019/optional-catch-binding/no-binding-finally/output.json b/packages/babel-parser/test/fixtures/es2019/optional-catch-binding/no-binding-finally/output.json index 4ebb1d0cb5..564ba035b4 100644 --- a/packages/babel-parser/test/fixtures/es2019/optional-catch-binding/no-binding-finally/output.json +++ b/packages/babel-parser/test/fixtures/es2019/optional-catch-binding/no-binding-finally/output.json @@ -93,7 +93,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": { "type": "BlockStatement", "start": 28, diff --git a/packages/babel-parser/test/fixtures/es2019/optional-catch-binding/no-binding/output.json b/packages/babel-parser/test/fixtures/es2019/optional-catch-binding/no-binding/output.json index 5124fdabae..0948185b8e 100644 --- a/packages/babel-parser/test/fixtures/es2019/optional-catch-binding/no-binding/output.json +++ b/packages/babel-parser/test/fixtures/es2019/optional-catch-binding/no-binding/output.json @@ -93,7 +93,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/empty-pattern-catch-param/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/empty-pattern-catch-param/output.json index 3074e479af..91b8476699 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/empty-pattern-catch-param/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/empty-pattern-catch-param/output.json @@ -108,7 +108,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch/output.json index 3dd5d0d3ca..48dd0332f9 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/patterned-catch/output.json @@ -476,7 +476,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/with-default-catch-param/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/with-default-catch-param/output.json index 7a2f7e482f..3ea9eda80f 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/with-default-catch-param/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-array-pattern/with-default-catch-param/output.json @@ -161,7 +161,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-object-pattern/empty-catch-param/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-object-pattern/empty-catch-param/output.json index 8cd3932ae8..528fb144b2 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-object-pattern/empty-catch-param/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-object-pattern/empty-catch-param/output.json @@ -108,7 +108,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-catch-parameter/output.json b/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-catch-parameter/output.json index 310a6b5e03..1fad434f6a 100644 --- a/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-catch-parameter/output.json +++ b/packages/babel-parser/test/fixtures/esprima/es2015-yield/yield-catch-parameter/output.json @@ -109,7 +109,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0000/output.json b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0000/output.json index d363a5d4cc..7124a7ba6f 100644 --- a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0000/output.json +++ b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0000/output.json @@ -109,7 +109,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0001/output.json b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0001/output.json index 80dde4eca4..0f104da5ae 100644 --- a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0001/output.json +++ b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0001/output.json @@ -109,7 +109,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0002/output.json b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0002/output.json index 4b11f881de..8721f9d984 100644 --- a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0002/output.json +++ b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0002/output.json @@ -109,7 +109,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0003/output.json b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0003/output.json index fbcb70be26..49094bb0e6 100644 --- a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0003/output.json +++ b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0003/output.json @@ -176,7 +176,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0004/output.json b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0004/output.json index ea48a40300..b1589f69dc 100644 --- a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0004/output.json +++ b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0004/output.json @@ -61,7 +61,6 @@ "directives": [] }, "handler": null, - "guardedHandlers": [], "finalizer": { "type": "BlockStatement", "start": 16, diff --git a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0005/output.json b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0005/output.json index bc19c5698f..7bb5acfbed 100644 --- a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0005/output.json +++ b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0005/output.json @@ -225,7 +225,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0006/output.json b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0006/output.json index dc667d97ef..91b0085400 100644 --- a/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0006/output.json +++ b/packages/babel-parser/test/fixtures/esprima/statement-try/migrated_0006/output.json @@ -225,7 +225,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": { "type": "BlockStatement", "start": 47, diff --git a/packages/babel-parser/test/fixtures/experimental/class-private-methods/async-generator/output.json b/packages/babel-parser/test/fixtures/experimental/class-private-methods/async-generator/output.json index 2ec8a62bd6..15456d810c 100644 --- a/packages/babel-parser/test/fixtures/experimental/class-private-methods/async-generator/output.json +++ b/packages/babel-parser/test/fixtures/experimental/class-private-methods/async-generator/output.json @@ -523,7 +523,6 @@ "directives": [] }, "handler": null, - "guardedHandlers": [], "finalizer": { "type": "BlockStatement", "start": 173, diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/output.json index 919b778030..a2feff08dc 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-finally-clause-with-catch-and-finally/output.json @@ -398,7 +398,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": { "type": "BlockStatement", "start": 98, diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/output.json index 56532830c7..95c03c8c90 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch-and-finally/output.json @@ -396,7 +396,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": { "type": "BlockStatement", "start": 91, diff --git a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/output.json b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/output.json index 1eaf755517..cf2f95415e 100644 --- a/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/output.json +++ b/packages/babel-parser/test/fixtures/experimental/pipeline-operator/proposal-smart-topic-style,-do-expression,-try-statement,-outer-topic-reference-in-try-clause-with-catch/output.json @@ -396,7 +396,6 @@ "directives": [] } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/output.json b/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/output.json index 355f89df61..133cd26c2b 100644 --- a/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/output.json +++ b/packages/babel-parser/test/fixtures/placeholders/try/try-catch-finally/output.json @@ -125,7 +125,6 @@ "expectedNode": "BlockStatement" } }, - "guardedHandlers": [], "finalizer": { "type": "Placeholder", "start": 36, diff --git a/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/output.json b/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/output.json index cb39ff1418..8c1574395e 100644 --- a/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/output.json +++ b/packages/babel-parser/test/fixtures/placeholders/try/with-catch-param/output.json @@ -141,7 +141,6 @@ "expectedNode": "BlockStatement" } }, - "guardedHandlers": [], "finalizer": null } ], diff --git a/packages/babel-parser/test/helpers/runFixtureTests.js b/packages/babel-parser/test/helpers/runFixtureTests.js index 32d6f0e954..9e97ee46f7 100644 --- a/packages/babel-parser/test/helpers/runFixtureTests.js +++ b/packages/babel-parser/test/helpers/runFixtureTests.js @@ -166,6 +166,9 @@ function runTest(test, parseFunction) { const mis = misMatch(JSON.parse(test.expect.code), ast); if (mis) { + if (process.env.OVERWRITE) { + return save(test, ast); + } throw new Error(mis); } }