summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-12-11 23:41:41 -0800
committerGitHub <noreply@github.com>2024-12-11 23:41:41 -0800
commit772c48af91951bda9ff7064fc7a089550c759f76 (patch)
tree0ee080c69fcd30e4ffe1b2c255af77f977661068
parent626e81478f2bcf759567975a3c94478374d1811d (diff)
Fix language server check skipping when explicit module decl exists. (#5845)
-rw-r--r--source/slang/slang-check-decl.cpp3
-rw-r--r--source/slang/slang-compiler.h2
-rw-r--r--tests/language-server/check-skip-module.slang16
3 files changed, 20 insertions, 1 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 7f07444dc..e94a3eb10 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -1356,7 +1356,8 @@ bool SemanticsVisitor::shouldSkipChecking(Decl* decl, DeclCheckState state)
auto& assistInfo = getLinkage()->contentAssistInfo;
// If this func is not defined in the primary module, skip checking its body.
auto moduleDecl = getModuleDecl(decl);
- if (moduleDecl && moduleDecl->getName() != assistInfo.primaryModuleName)
+ if (moduleDecl && moduleDecl->module->getNameObj() != assistInfo.primaryModuleName &&
+ moduleDecl->getName() != assistInfo.primaryModuleName)
return true;
if (funcDecl->body)
{
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index e0df18a8c..cc4fc8dcc 100644
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -1660,6 +1660,8 @@ public:
void setName(String name);
void setName(Name* name) { m_name = name; }
+ Name* getNameObj() { return m_name; }
+
void setPathInfo(PathInfo pathInfo) { m_pathInfo = pathInfo; }
/// Set the IR for this module.
diff --git a/tests/language-server/check-skip-module.slang b/tests/language-server/check-skip-module.slang
new file mode 100644
index 000000000..fd5c0d9ff
--- /dev/null
+++ b/tests/language-server/check-skip-module.slang
@@ -0,0 +1,16 @@
+//TEST:LANG_SERVER(filecheck=CHECK):
+module module_A;
+struct A {
+ int x;
+ int y;
+};
+
+[numthreads(1,1,1)]
+void main()
+{
+//HOVER:12,5
+ A a;
+ a.x = 2;
+}
+
+// CHECK: struct A \ No newline at end of file