Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
40df65e
fix(graph): skip import edges for lexically shadowed require (#2890)
hussnainahmedd Oct 13, 2026
4c4c273
fix(graph): address review findings on shadowed-require detection
hussnainahmedd Oct 13, 2026
8ef0dd1
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 13, 2026
4c7faad
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 13, 2026
3e26716
fix(graph): address greptile review findings on loader exemptions
hussnainahmedd Oct 13, 2026
92e2783
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 13, 2026
e8b8bed
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 13, 2026
3d0f980
fix(graph): verify loader-parameter bindings positionally and accept …
hussnainahmedd Oct 13, 2026
4173418
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 13, 2026
84ea39f
fix(graph): make require-loader checks positional for writes, keys, a…
hussnainahmedd Oct 14, 2026
87049c7
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 14, 2026
0c1aca4
fix(graph): require writes to provably run before shadowing a call
hussnainahmedd Oct 14, 2026
b3e1522
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 14, 2026
dd6c1a2
fix(graph): instance field writes shadow calls in later fields
hussnainahmedd Oct 14, 2026
453a31a
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 14, 2026
9a09003
fix(graph): restore loader on later createRequire writes
hussnainahmedd Oct 14, 2026
8659198
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 14, 2026
a6e6555
fix(graph): guard createRequire establishing writes by must-run and p…
hussnainahmedd Oct 14, 2026
e8111ff
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 14, 2026
5b49524
fix(graph): honor for-initializer and class-evaluation order in shado…
hussnainahmedd Oct 14, 2026
82859a2
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 14, 2026
68cb6c6
fix(graph): honor do-while body execution in shadowed-require analysis
hussnainahmedd Oct 14, 2026
b633841
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 14, 2026
f3a4463
fix(graph): honor createRequire alias established inside a branch
hussnainahmedd Oct 14, 2026
c8030ec
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 14, 2026
6b9f061
fix(graph): honor loop-condition writes in shadowed-require analysis
hussnainahmedd Oct 14, 2026
c7017dc
Merge branch 'main' into fix/2890-shadowed-require
hussnainahmedd Oct 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/domain/javascript/javascriptSemanticAnalysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ interface BindPatternInput {
readonly state: JavaScriptSemanticAnalysisState;
readonly mutable: boolean;
readonly kind?: JavaScriptSemanticDefinition["kind"];
readonly declarationKind?: JavaScriptSemanticDefinition["declarationKind"];
readonly projection?: readonly (string | number | null)[];
readonly referenceOnly?: boolean;
readonly copyKind?: "object-rest" | "array-rest";
Expand All @@ -100,6 +101,7 @@ interface AddBindingInput {
readonly mutable: boolean;
readonly definitionNode: t.Node;
readonly initializer: t.Node | null;
readonly declarationKind?: JavaScriptSemanticDefinition["declarationKind"];
readonly directOrigin?: JavaScriptModuleOrigin;
readonly runtimeImport?: boolean;
readonly projection?: readonly (string | number | null)[];
Expand Down Expand Up @@ -876,6 +878,14 @@ const bindInnerDeclaration = (
parent !== null && t.isVariableDeclaration(parent)
? parent.kind !== "const"
: true,
declarationKind:
parent !== null && t.isVariableDeclaration(parent)
? parent.kind === "var" ||
parent.kind === "let" ||
parent.kind === "const"
? parent.kind
: undefined
: undefined,
});
else if (t.isClassExpression(node) && t.isIdentifier(node.id))
addBinding({
Expand Down Expand Up @@ -1154,6 +1164,7 @@ const bindPattern = (input: BindPatternInput): void => {
state,
mutable,
kind = "variable",
declarationKind,
projection = [],
referenceOnly = false,
copyKind,
Expand Down Expand Up @@ -1198,6 +1209,7 @@ const bindPattern = (input: BindPatternInput): void => {
definitionNode: pattern,
initializer,
projection,
...(declarationKind === undefined ? {} : { declarationKind }),
});
return;
}
Expand Down Expand Up @@ -1299,6 +1311,7 @@ const addBinding = (input: AddBindingInput): void => {
mutable,
definitionNode,
initializer,
declarationKind,
directOrigin,
runtimeImport,
projection = [],
Expand All @@ -1311,7 +1324,11 @@ const addBinding = (input: AddBindingInput): void => {
state.bindingsById.set(binding.bindingId, binding);
}
binding.mutable ||= mutable;
binding.definitions.push({ kind, location: range(definitionNode) });
binding.definitions.push({
kind,
location: range(definitionNode),
...(declarationKind === undefined ? {} : { declarationKind }),
});
if (initializer !== null)
binding.initializers.push({ node: initializer, projection });
if (directOrigin !== undefined)
Expand Down
6 changes: 6 additions & 0 deletions src/domain/javascript/javascriptSemanticIr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ export interface JavaScriptSemanticDefinition {
| "catch"
| "assignment";
readonly location: JavaScriptSourceRange;
/**
* The `VariableDeclaration` kind (`var`, `let`, `const`) for a `variable`
* definition. Recorded so consumers can distinguish hoisted `var`
* declarations from block-scoped `let`/`const` without reparsing.
*/
readonly declarationKind?: "var" | "let" | "const";
}

/** One resolved lexical binding plus static value and provenance. */
Expand Down
6 changes: 6 additions & 0 deletions src/domain/javascript/javascriptStaticAnalysisBundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as t from "@babel/types";
import { javascriptBootstrapAt } from "./javascriptBootstrap.js";
import {
resolveSemanticBindingState,
semanticScopeId,
type JavaScriptSemanticAnalysisState,
} from "./javascriptSemanticState.js";

Expand Down Expand Up @@ -259,6 +260,11 @@ const recoverBundlerModule = (
key,
runtime,
requireName,
// The factory's own scope always exists: the semantic pass creates one
// function scope per visited function node, and the factory is part of
// the analyzed source.
loaderScopeId:
requireName === "require" ? semanticScopeId("function", factory) : null,
};
accumulator.moduleRangeIndex.add(moduleRange);
}
Expand Down
Loading