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 authored and GitHub committed 2026-10-16 04:35:54 +08:00
1 parent e2db768012
commit 0cc56493be
13 files changed
+1286 -273

No files matched your search

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