fix(javascript): correct lexical and dynamic scope analysis (#538)

* fix(javascript): gate CommonJS exports on unshadowed globals and record dynamic scope

* fix(javascript): correct dynamic and switch scope boundaries
This commit is contained in:
morluto
2026-10-05 23:42:48 +08:00
committed by GitHub
parent 00fa97422f
commit 6fa6f1f9b1
13 changed files with 337 additions and 28 deletions
+13 -2
View File
@@ -44,7 +44,13 @@ export type JavaScriptBindingProvenance =
export interface JavaScriptSemanticScope {
readonly scopeId: string;
readonly parentScopeId: string | null;
readonly kind: "program" | "function" | "block" | "class" | "catch";
readonly kind:
| "program"
| "function"
| "block"
| "static-block"
| "class"
| "catch";
readonly location: JavaScriptSourceRange;
readonly bindingsComplete: boolean;
readonly bindingIds: readonly string[];
@@ -369,7 +375,12 @@ export interface JavaScriptSemanticObjectOperation {
/** One syntax location where exact local semantic continuation is unavailable. */
export interface JavaScriptSemanticFrontier {
readonly kind: "dynamic-call" | "dynamic-property";
/**
* `dynamic-call`/`dynamic-property` mark a callee or key the analyzer could
* not resolve. `dynamic-scope` marks `with`/`eval`, where the binding
* environment itself is not statically knowable.
*/
readonly kind: "dynamic-call" | "dynamic-property" | "dynamic-scope";
readonly callableId: string | null;
readonly location: JavaScriptSourceRange;
readonly reason: string;