From 59ecfecb9ed727b0e35e4f0dcea84c28dbc98d5c Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Tue, 3 Nov 2015 04:17:38 +0000 Subject: [PATCH] fix indentation and skip check for references that are inside the function we're checking execution status against --- .../babel-traverse/src/path/introspection.js | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/packages/babel-traverse/src/path/introspection.js b/packages/babel-traverse/src/path/introspection.js index a333a49ab9..409e4fa587 100644 --- a/packages/babel-traverse/src/path/introspection.js +++ b/packages/babel-traverse/src/path/introspection.js @@ -298,7 +298,7 @@ export function _guessExecutionStatusRelativeToDifferentFunctions(targetFuncPare // no references! if (!binding.references) return "before"; - let referencePaths: Array = binding.referencePaths; + let referencePaths: Array = binding.referencePaths; // verify that all of the references are calls for (let path of referencePaths) { @@ -309,17 +309,23 @@ export function _guessExecutionStatusRelativeToDifferentFunctions(targetFuncPare let allStatus; - // verify that all the calls have the same execution status - for (let path of referencePaths) { - let status = this._guessExecutionStatusRelativeTo(path); - if (allStatus) { - if (allStatus !== status) return; - } else { - allStatus = status; - } - } + // verify that all the calls have the same execution status + for (let path of referencePaths) { + // if a reference is a child of the function we're checking against then we can + // safelty ignore it + let childOfFunction = !!path.find(path => path === targetFuncPath); + if (childOfFunction) continue; - return allStatus; + let status = this._guessExecutionStatusRelativeTo(path); + + if (allStatus) { + if (allStatus !== status) return; + } else { + allStatus = status; + } + } + + return allStatus; } /**