summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-parser.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-27 12:21:07 -0700
committerGitHub <noreply@github.com>2024-03-27 12:21:07 -0700
commit8395acfa0ad8379011e4470b94362189cafac93f (patch)
tree4395205a3969d2cd3d3b6407fa77786b26aec809 /source/slang/slang-parser.cpp
parentc5369d507341e6b6fe64d4e6f26e194cd39235ca (diff)
Fix lookup to prevent finding `typedef` itself. (#3848)
Diffstat (limited to 'source/slang/slang-parser.cpp')
-rw-r--r--source/slang/slang-parser.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/slang/slang-parser.cpp b/source/slang/slang-parser.cpp
index b99df18e4..cc3a661f3 100644
--- a/source/slang/slang-parser.cpp
+++ b/source/slang/slang-parser.cpp
@@ -2576,11 +2576,20 @@ namespace Slang
typeSpec.expr = parseFuncTypeExpr(parser);
return typeSpec;
}
+
+ bool inGlobalScope = false;
+ if (AdvanceIf(parser, TokenType::Scope))
+ {
+ inGlobalScope = true;
+ }
Token typeName = parser->ReadToken(TokenType::Identifier);
auto basicType = parser->astBuilder->create<VarExpr>();
- basicType->scope = parser->currentLookupScope;
+ if (inGlobalScope)
+ basicType->scope = parser->currentModule->ownedScope;
+ else
+ basicType->scope = parser->currentLookupScope;
basicType->loc = typeName.loc;
basicType->name = typeName.getNameOrNull();