Do not guess relative execution status for exported fns (#10417)

This commit is contained in:
Nicolò Ribaudo 2019-09-10 19:47:27 +02:00 committed by GitHub
parent 8027dca501
commit 610d6bdc62
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,14 @@
import { foo } from "somewhere";
// foo might call "bar"
foo();
a;
let a;
a;
export function bar() {
return a;
}

View File

@ -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");
}

View File

@ -0,0 +1,6 @@
const E_ARR = [];
export default function () {
const someVar = E_ARR;
return [...someVar];
}

View File

@ -0,0 +1,5 @@
const E_ARR = [];
export default function () {
const someVar = E_ARR;
return babelHelpers.toConsumableArray(someVar);
}

View File

@ -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