fix(javascript): preserve values captured before later assignments (#4196)

Select binding facts at reads without mixing whole-binding and temporal values. Share conditional activation rules, preserve partial expression order, and bound immutable ancestry work. Memoize temporal results within each query using initializer identity, capture point, budget and dependency proofs; preserve depth limits and source Evidence.

Fixes #3881
This commit is contained in:
Ysopwnable
2026-10-16 04:35:54 +08:00
committed by GitHub
parent e2db768012
commit 0cc56493be
13 changed files with 1286 additions and 273 deletions
@@ -16,6 +16,7 @@ export const runtimeFunctionParameters = (
*/
export const unwrapJavaScriptExpression = (
node: t.Node,
options?: { readonly stopAtParentheses: boolean },
): { readonly node: t.Node; readonly depth: number } => {
let current = node;
let depth = 0;
@@ -28,6 +29,14 @@ export const unwrapJavaScriptExpression = (
t.isTSInstantiationExpression(current) ||
t.isTypeCastExpression(current)
) {
// Optional-chain grouping affects execution even when expression identity
// is transparent. Keep every grouping boundary available to that consumer.
if (
options?.stopAtParentheses === true &&
(t.isParenthesizedExpression(current) ||
current.extra?.parenthesized === true)
)
break;
current = current.expression;
depth += 1;
}