Skip to content

Commit

Permalink
Do not guess relative execution status for exported fns (#10417)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Sep 10, 2019
1 parent 8027dca commit 610d6bd
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
@@ -0,0 +1,14 @@
import { foo } from "somewhere";

// foo might call "bar"
foo();

a;

let a;

a;

export function bar() {
return a;
}
@@ -0,0 +1,10 @@
var a = babelHelpers.temporalUndefined;
import { foo } from "somewhere"; // foo might call "bar"

foo();
babelHelpers.tdz("a");
a = void 0;
a;
export function bar() {
return babelHelpers.temporalRef(a, "a");
}
@@ -0,0 +1,6 @@
const E_ARR = [];

export default function () {
const someVar = E_ARR;
return [...someVar];
}
@@ -0,0 +1,5 @@
const E_ARR = [];
export default function () {
const someVar = E_ARR;
return babelHelpers.toConsumableArray(someVar);
}
7 changes: 6 additions & 1 deletion packages/babel-traverse/src/path/introspection.js
Expand Up @@ -370,7 +370,12 @@ const executionOrderCheckedNodes = new WeakSet();
export function _guessExecutionStatusRelativeToDifferentFunctions(
target: NodePath,
): RelativeExecutionStatus {
if (!target.isFunctionDeclaration()) return "unknown";
if (
!target.isFunctionDeclaration() ||
target.parentPath.isExportDeclaration()
) {
return "unknown";
}

// so we're in a completely different function, if this is a function declaration
// then we can be a bit smarter and handle cases where the function is either
Expand Down

0 comments on commit 610d6bd

Please sign in to comment.