add support for tail calls when in completion record position - fixes #1572
This commit is contained in:
@@ -34,6 +34,12 @@ var visitor = {
|
||||
return state.subTransform(node.argument);
|
||||
},
|
||||
|
||||
ExpressionStatement(node, parent, scope, state) {
|
||||
if (this.isCompletionRecord(true)) {
|
||||
return state.subTransform(node.expression);
|
||||
}
|
||||
},
|
||||
|
||||
Function() {
|
||||
this.skip();
|
||||
},
|
||||
|
||||
@@ -121,17 +121,20 @@ export function isPreviousType(type: string): boolean {
|
||||
* Check whether the current path references a completion record
|
||||
*/
|
||||
|
||||
export function isCompletionRecord() {
|
||||
export function isCompletionRecord(allowInsideFunction?) {
|
||||
var path = this;
|
||||
var first = true;
|
||||
|
||||
do {
|
||||
var container = path.container;
|
||||
|
||||
// we're in a function so can't be a completion record
|
||||
if (path.isFunctionDeclaration()) {
|
||||
return false;
|
||||
if (path.isFunction() && !first) {
|
||||
return !!allowInsideFunction;
|
||||
}
|
||||
|
||||
first = false;
|
||||
|
||||
// check to see if we're the last item in the container and if we are
|
||||
// we're a completion record!
|
||||
if (Array.isArray(container) && path.key !== container.length - 1) {
|
||||
|
||||
Reference in New Issue
Block a user