diff options
| author | Yong He <yonghe@outlook.com> | 2024-03-20 13:33:13 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-20 13:33:13 -0700 |
| commit | c28a22fb8b505ff48ca0814ca290ee4f698aa38b (patch) | |
| tree | 30cf242ae893c6dee3a3fdd3cf6228ffb01e2029 /source | |
| parent | 04ffa84c95b68ae50c25d32703fa9e6d49d2a10a (diff) | |
Fix namespace parsing. (#3803)
* Fix namespace parsing.
* Fix.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-parser.cpp | 16 |
1 files changed, 6 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)); |
