summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-27 13:03:28 -0700
committerGitHub <noreply@github.com>2024-03-27 13:03:28 -0700
commitb346a9333ae6d09f053db60b3006e6e074332ac2 (patch)
treeddbbd33bb93fb858deb8c2c94b8905d8e2c562ea /source
parent8395acfa0ad8379011e4470b94362189cafac93f (diff)
Allow var/param names to be the same as type name. (#3850)
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-check-decl.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index ed97e412d..78eccbc8c 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -1547,7 +1547,8 @@ namespace Slang
}
else
{
- initExpr = CheckExpr(initExpr);
+ SemanticsVisitor subVisitor(withDeclToExcludeFromLookup(varDecl));
+ initExpr = subVisitor.CheckExpr(initExpr);
// TODO: We might need some additional steps here to ensure
// that the type of the expression is one we are okay with
@@ -1568,7 +1569,8 @@ namespace Slang
{
// A variable with an explicit type is simpler, for the
// most part.
- TypeExp typeExp = CheckUsableType(varDecl->type);
+ SemanticsVisitor subVisitor(withDeclToExcludeFromLookup(varDecl));
+ TypeExp typeExp = subVisitor.CheckUsableType(varDecl->type);
varDecl->type = typeExp;
if (varDecl->type.equals(m_astBuilder->getVoidType()))
{
@@ -6998,7 +7000,8 @@ namespace Slang
auto typeExpr = paramDecl->type;
if(typeExpr.exp)
{
- typeExpr = CheckUsableType(typeExpr);
+ SemanticsVisitor subVisitor(withDeclToExcludeFromLookup(paramDecl));
+ typeExpr = subVisitor.CheckUsableType(typeExpr);
paramDecl->type = typeExpr;
checkMeshOutputDecl(paramDecl);
}
@@ -7640,7 +7643,8 @@ namespace Slang
void SemanticsDeclHeaderVisitor::visitPropertyDecl(PropertyDecl* decl)
{
- decl->type = CheckUsableType(decl->type);
+ SemanticsVisitor subVisitor(withDeclToExcludeFromLookup(decl));
+ decl->type = subVisitor.CheckUsableType(decl->type);
visitAbstractStorageDeclCommon(decl);
checkVisibility(decl);
}