fix(javascript): preserve global escapes across callback boundaries

This commit is contained in:
RRFZ authored and Ysopwnable committed 2026-11-14 04:46:27 +01:00
1 parent 54677ec1d6
commit 4e1e9b62a7
2 files changed
+32 -11

No files matched your search

@@ -965,17 +965,19 @@ const createGlobalPathRead = (
// That escape cannot have replaced the callee before the call selects it.
const escapePrecedesRead = effects.escapes.some((effect) => {
const escape = effect.node;
if (
escape !== undefined &&
escape !== site &&
typeof escape.start === "number" &&
typeof escape.end === "number" &&
typeof site.start === "number" &&
typeof site.end === "number" &&
site.start >= escape.start &&
site.end <= escape.end
)
return false;
// Containment alone does not order deferred callback/class bodies.
// Only a read reached without crossing such a boundary precedes escape.
if (escape !== undefined && escape !== site) {
let parent = state.parentsByNode.get(site);
while (
parent !== undefined &&
!t.isFunction(parent) &&
!t.isClass(parent)
) {
if (parent === escape) return false;
parent = state.parentsByNode.get(parent);
}
}
return semanticEffectTiming(site, escape, state) !== "after";
});
if (