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:
@@ -138,3 +138,13 @@ export const semanticVariableScope = (
|
||||
}
|
||||
return candidate;
|
||||
};
|
||||
|
||||
/** Identify a global name only when no lexical or dynamic environment shadows it. */
|
||||
export const isUnshadowedGlobal = (
|
||||
node: t.Node,
|
||||
state: JavaScriptSemanticAnalysisState,
|
||||
name: string,
|
||||
): boolean =>
|
||||
t.isIdentifier(node, { name }) &&
|
||||
resolveSemanticBindingState(state, node, name) === undefined &&
|
||||
!semanticResolutionBlocked(state, node, name);
|
||||
|
||||
Reference in New Issue
Block a user