From 32eabf620b9d5eaf190969cc4a38f7775626a3f3 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Wed, 22 Mar 2017 10:25:10 +0100 Subject: [PATCH] Fix push-pop logic in flow (#405) --- src/plugins/flow.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/plugins/flow.js b/src/plugins/flow.js index 163918cdd4..9592064400 100644 --- a/src/plugins/flow.js +++ b/src/plugins/flow.js @@ -1377,10 +1377,10 @@ export default function (instance) { } } - // Need to push something onto the context to stop - // the JSX plugin from messing with the tokens - this.state.context.push(ct.parenExpression); if (jsxError != null || this.isRelational("<")) { + // Need to push something onto the context to stop + // the JSX plugin from messing with the tokens + this.state.context.push(ct.parenExpression); let arrowExpression; let typeParameters; try { @@ -1390,9 +1390,13 @@ export default function (instance) { arrowExpression.typeParameters = typeParameters; this.resetStartLocationFromNode(arrowExpression, typeParameters); } catch (err) { + this.state.context.pop(); + throw jsxError || err; } + this.state.context.pop(); + if (arrowExpression.type === "ArrowFunctionExpression") { return arrowExpression; } else if (jsxError != null) { @@ -1404,7 +1408,6 @@ export default function (instance) { ); } } - this.state.context.pop(); return inner.apply(this, args); };