summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--source/slang/slang-parser.cpp16
-rw-r--r--tests/bugs/gh-3802.slang11
2 files changed, 17 insertions, 10 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index e1dce5731..ab69b66d8 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -3457,22 +3457,18 @@ namespace Slang
namespaceDecl = parser->astBuilder->create<NamespaceDecl>();
namespaceDecl->nameAndLoc = nameAndLoc;
namespaceDecl->loc = nameAndLoc.loc;
+ AddMember(parentDecl, namespaceDecl);
+ if (auto parentNamespace = as<NamespaceDecl>(parentDecl))
+ {
+ parser->PushScope(parentDecl);
+ nestedNamespaceDecls.add(parentNamespace);
+ }
}
}
if (!result)
{
result = namespaceDecl;
}
- else if (parentDecl)
- {
- if (auto parentNamespace = as<NamespaceDecl>(parentDecl))
- {
- parser->PushScope(parentDecl);
- nestedNamespaceDecls.add(parentNamespace);
- }
- AddMember(parentDecl, namespaceDecl);
- }
-
parentDecl = namespaceDecl;
} while (AdvanceIf(parser, TokenType::Dot) || AdvanceIf(parser, TokenType::Scope));
diff --git a/tests/bugs/gh-3802.slang b/tests/bugs/gh-3802.slang
new file mode 100644
index 000000000..7b09592f3
--- /dev/null
+++ b/tests/bugs/gh-3802.slang
@@ -0,0 +1,11 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv -emit-spirv-directly
+
+namespace foo::bar::baz {}
+namespace foo::bar {} // <- leaving this out "fixes" the issue
+
+// CHECK: OpEntryPoint
+
+[shader("compute")]
+[numthreads(1, 1, 1)]
+void computeMain()
+{} \ No newline at end of file