Skip to content

Commit

Permalink
Wrap callback in try/finally
Browse files Browse the repository at this point in the history
This ensures we clean up always if the callback throws.
  • Loading branch information
mAAdhaTTah committed Jul 22, 2018
1 parent afd0638 commit 094ef31
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/babel-parser/src/parser/expression.js
Expand Up @@ -2131,10 +2131,11 @@ export default class ExpressionParser extends LValParser {
maxTopicIndex: null,
};

const callbackResult = callback();

this.state.topicContext = outerContextTopicState;
return callbackResult;
try {
return callback();
} finally {
this.state.topicContext = outerContextTopicState;
}
}

// Disable topic references from outer contexts within syntax constructs
Expand All @@ -2153,10 +2154,11 @@ export default class ExpressionParser extends LValParser {
maxTopicIndex: null,
};

const callbackResult = callback();

this.state.topicContext = outerContextTopicState;
return callbackResult;
try {
return callback();
} finally {
this.state.topicContext = outerContextTopicState;
}
}

// Register the use of a primary topic reference (`#`) within the current
Expand Down

0 comments on commit 094ef31

Please sign in to comment.