summaryrefslogtreecommitdiffstats
path: root/source/slang/check.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/check.cpp')
-rw-r--r--source/slang/check.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/slang/check.cpp b/source/slang/check.cpp
index 463052bc8..582f19448 100644
--- a/source/slang/check.cpp
+++ b/source/slang/check.cpp
@@ -52,6 +52,14 @@ namespace Slang
// lexical outer statements
List<StatementSyntaxNode*> outerStmts;
+
+ // We need to track what has been `import`ed,
+ // to avoid importing the same thing more than once
+ //
+ // TODO: a smarter approach might be to filter
+ // out duplicate references during lookup.
+ HashSet<ProgramSyntaxNode*> importedModules;
+
public:
SemanticsVisitor(
DiagnosticSink * pErr,
@@ -4909,6 +4917,15 @@ namespace Slang
// it later during code generation.
decl->importedModuleDecl = importedModuleDecl;
+ // If we've imported this one already, then
+ // skip the step where we modify the current scope.
+ if (importedModules.Contains(importedModuleDecl.Ptr()))
+ {
+ return;
+ }
+ importedModules.Add(importedModuleDecl.Ptr());
+
+
// Create a new sub-scope to wire the module
// into our lookup chain.
auto subScope = new Scope();