Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not guess relative execution status for exported fns #10417

Merged
merged 1 commit into from Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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()
JLHwung marked this conversation as resolved.
Show resolved Hide resolved
) {
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