From b346a9333ae6d09f053db60b3006e6e074332ac2 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 27 Mar 2024 13:03:28 -0700 Subject: Allow var/param names to be the same as type name. (#3850) --- source/slang/slang-check-decl.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'source') 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); } -- cgit v1.2.3