fix(javascript): preserve capture and property-key effect ownership

This commit is contained in:
morluto
2026-10-24 04:14:34 +08:00
parent b3433d0187
commit c6ac60acfe
7 changed files with 129 additions and 7 deletions
@@ -1016,6 +1016,12 @@ export const semanticCapturePosition = (
semanticStaticPropertyKey(parent.key, parent.computed) !== null
)
current = parent;
else if (
t.isSpreadElement(parent) &&
parent.argument === current &&
t.isObjectExpression(parents.get(parent))
)
current = parent;
else if (t.isObjectExpression(parent) || t.isArrayExpression(parent))
current = parent;
else return null;
@@ -1069,6 +1075,8 @@ export const semanticEscapeFollowsCapture = (
!semanticBindingPrecedesCapture(binding, capture, parents)
)
return false;
if (scopeExitOwners.has(escape))
return semanticEffectFollowsReference(capture, escape, parents);
// A literal allocates here. Aliases are evaluated at the same capture point,
// so an outer/persistent origin still receives all of its own escape effects.
const origin = unwrapJavaScriptExpression(initializer.node).node;