fix(javascript): keep array presence snapshots query-owned (#12511)

Reuse the capture-lifetime approach from #7716 for ordinary array-read proof.

Co-authored-by: SII-YDD <38822679+SII-YDD@users.noreply.github.com>
This commit is contained in:
morlutoandSII-YDD authored and GitHub committed 2026-11-19 20:24:36 +00:00
1 parent e46ace9744
commit 83192e9750
4 files changed
+142 -20

No files matched your search

@@ -53,23 +53,16 @@ export const semanticKnownArrayIteration = (
!ambientPathMayObserveAt(state, read, arrayIteratorNextPath, "contents") &&
value.items.every((item) => semanticArrayIndex(item.name) !== null);
/**
* Return the array that admits native iteration at this read. A plain array's
* numeric properties are the values consumed by its native iterator.
*/
export const semanticNativeArrayIterationValueAt = (
node: t.Node,
state: JavaScriptSemanticAnalysisState,
) => {
const value = evaluateSemanticExpression(node, state, node);
return semanticKnownArrayIteration(value, state, node) ? value : undefined;
};
/** Invocation spreads use the same native-iteration proof at their source read. */
export const semanticKnownArrayIterationAt = (
node: t.Node,
state: JavaScriptSemanticAnalysisState,
): boolean => semanticNativeArrayIterationValueAt(node, state) !== undefined;
): boolean =>
semanticKnownArrayIteration(
evaluateSemanticExpression(node, state, node),
state,
node,
);
/** Numeric destructuring projections do not select slots of custom iterators. */
export const semanticReferenceIterationUnknown = (