diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index ed97e412db..78eccbc8ca 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); } diff --git a/tests/bugs/gh-3824.slang b/tests/bugs/gh-3824.slang new file mode 100644 index 0000000000..1d2d3685f3 --- /dev/null +++ b/tests/bugs/gh-3824.slang @@ -0,0 +1,20 @@ +//TEST:SIMPLE(filecheck=CHECK):-target spirv -emit-spirv-directly + +// CHECK: OpEntryPoint + +namespace example { + struct Example {} +} + +struct Struct { + example::Example example; +} + +void func(Struct Struct) +{ + // Test parameter name to be the same as type name. +} + +[numthreads(1,1,1)] +void main() +{} \ No newline at end of file