Skip to content

Commit

Permalink
Remove guardedHandlers from ASTs (#9979)
Browse files Browse the repository at this point in the history
  • Loading branch information
danez committed May 15, 2019
1 parent 1969e6b commit 85432e2
Show file tree
Hide file tree
Showing 36 changed files with 3 additions and 41 deletions.
5 changes: 0 additions & 5 deletions packages/babel-parser/src/parser/statement.js
Expand Up @@ -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" };

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions packages/babel-parser/src/types.js
Expand Up @@ -263,8 +263,6 @@ export type TryStatement = NodeBase & {
block: BlockStatement,
handler: CatchClause | null,
finalizer: BlockStatement | null,

guardedHandlers: $ReadOnlyArray<empty>, // TODO: Not in spec
};

export type CatchClause = NodeBase & {
Expand Down
Expand Up @@ -198,7 +198,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
},
{
Expand Down
Expand Up @@ -238,14 +238,12 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
},
{
Expand Down
Expand Up @@ -161,7 +161,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -176,7 +176,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -61,7 +61,6 @@
"directives": []
},
"handler": null,
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 16,
Expand Down
Expand Up @@ -225,7 +225,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -225,7 +225,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 47,
Expand Down
Expand Up @@ -164,7 +164,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -93,7 +93,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 28,
Expand Down
Expand Up @@ -93,7 +93,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -108,7 +108,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -476,7 +476,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -161,7 +161,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -108,7 +108,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -109,7 +109,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -176,7 +176,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -61,7 +61,6 @@
"directives": []
},
"handler": null,
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 16,
Expand Down
Expand Up @@ -225,7 +225,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -225,7 +225,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 47,
Expand Down
Expand Up @@ -523,7 +523,6 @@
"directives": []
},
"handler": null,
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 173,
Expand Down
Expand Up @@ -398,7 +398,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 98,
Expand Down
Expand Up @@ -396,7 +396,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": {
"type": "BlockStatement",
"start": 91,
Expand Down
Expand Up @@ -396,7 +396,6 @@
"directives": []
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
Expand Up @@ -125,7 +125,6 @@
"expectedNode": "BlockStatement"
}
},
"guardedHandlers": [],
"finalizer": {
"type": "Placeholder",
"start": 36,
Expand Down
Expand Up @@ -141,7 +141,6 @@
"expectedNode": "BlockStatement"
}
},
"guardedHandlers": [],
"finalizer": null
}
],
Expand Down
3 changes: 3 additions & 0 deletions packages/babel-parser/test/helpers/runFixtureTests.js
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 85432e2

Please sign in to comment.