fix(javascript): respect lexical shadowing of require (#509)
Signed-off-by: RudyCelekli <47457359+rudycelekli@users.noreply.github.com>
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
collectSemanticReferences,
|
||||
immutableSemanticBindings,
|
||||
immutableSemanticScopes,
|
||||
semanticModuleOrigin,
|
||||
semanticStaticPropertyName,
|
||||
} from "./javascriptSemanticProjection.js";
|
||||
import type {
|
||||
@@ -77,6 +76,9 @@ export const analyzeParsedJavaScriptSemantics = (
|
||||
): JavaScriptSemanticIr => {
|
||||
const state = createState(file.program);
|
||||
collectDefinitions(file.program, state);
|
||||
traverseJavaScriptAst(file.program, {
|
||||
enter: (node) => collectSemanticModuleLink(node, state),
|
||||
});
|
||||
const references = collectSemanticReferences(file.program, state);
|
||||
const parserPartial = file.errors.length > 0;
|
||||
const bindings = immutableSemanticBindings(state);
|
||||
@@ -159,7 +161,6 @@ const collectDefinitions = (
|
||||
state,
|
||||
});
|
||||
bindInnerDeclaration(node, parent, scope, state);
|
||||
collectSemanticModuleLink(node, state);
|
||||
},
|
||||
exit: (node) => {
|
||||
if (openedScopes.has(node)) stack.pop();
|
||||
@@ -329,17 +330,6 @@ const bindPattern = (input: BindPatternInput): void => {
|
||||
return;
|
||||
}
|
||||
if (t.isIdentifier(pattern)) {
|
||||
const baseOrigin = semanticModuleOrigin(initializer, []);
|
||||
const directOrigin =
|
||||
baseOrigin === undefined || projection.includes(null)
|
||||
? undefined
|
||||
: {
|
||||
...baseOrigin,
|
||||
importedPath: [
|
||||
...baseOrigin.importedPath,
|
||||
...projection.map((segment) => String(segment)),
|
||||
],
|
||||
};
|
||||
addBinding({
|
||||
state,
|
||||
scope,
|
||||
@@ -348,7 +338,6 @@ const bindPattern = (input: BindPatternInput): void => {
|
||||
mutable,
|
||||
definitionNode: pattern,
|
||||
initializer,
|
||||
...(directOrigin === undefined ? {} : { directOrigin }),
|
||||
projection,
|
||||
});
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user