diff --git a/packages/babel-parser/src/parser/statement.js b/packages/babel-parser/src/parser/statement.js index 0e83b088cc15..f47b80448b10 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 22ceb9e2dfa8..2c5992d2ba6c 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 b576780b7063..a465e0c09fb0 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 677fad5fcdc7..8c0ce7e4c006 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 6b4c229346ab..1baae9250df9 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 439f7f105f01..f9626718bb97 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 66d668784cab..54bc80b8062d 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 d363a5d4cc63..7124a7ba6fff 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 80dde4eca487..0f104da5ae82 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 4b11f881deec..8721f9d98403 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 fbcb70be2667..49094bb0e6bd 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 ea48a4030059..b1589f69dcee 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 bc19c5698fbf..7bb5acfbedbb 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 dc667d97efc5..91b008540089 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 a66c95114fd8..1714f8b7d8a3 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 4ebb1d0cb5c5..564ba035b454 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 5124fdabae39..0948185b8e4e 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 3074e479af9d..91b847669991 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 3dd5d0d3ca93..48dd0332f9cd 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 7a2f7e482fae..3ea9eda80fdc 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 8cd3932ae874..528fb144b23c 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 310a6b5e033c..1fad434f6ac5 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 d363a5d4cc63..7124a7ba6fff 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 80dde4eca487..0f104da5ae82 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 4b11f881deec..8721f9d98403 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 fbcb70be2667..49094bb0e6bd 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 ea48a4030059..b1589f69dcee 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 bc19c5698fbf..7bb5acfbedbb 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 dc667d97efc5..91b008540089 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 2ec8a62bd6d2..15456d810c09 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 919b7780300e..a2feff08dcac 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 56532830c7a7..95c03c8c90e3 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 1eaf75551753..cf2f95415e23 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 355f89df612f..133cd26c2bbb 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 cb39ff141899..8c1574395e8d 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 32d6f0e95452..9e97ee46f727 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); } }