Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/slang/slang-check-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,9 @@ Expr* SemanticsVisitor::maybeUseSynthesizedDeclForLookupResult(
conformanceDecl->base.type = m_astBuilder->getDiffInterfaceType();
structDecl->addMember(conformanceDecl);
structDecl->parentDecl = parent;
structDecl->ownedScope = m_astBuilder->create<Scope>();
structDecl->ownedScope->containerDecl = structDecl;
structDecl->ownedScope->parent = getScope(parent);

synthesizedDecl = structDecl;
auto typeDef = m_astBuilder->create<TypeAliasDecl>();
Expand Down
31 changes: 31 additions & 0 deletions tests/bugs/gh-6756.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//TEST:SIMPLE(filecheck=CHECK):-target spirv -emit-spirv-via-glsl

// This test is to test that PartlyDiffable.Differential is synthesized
// with correct scope. If not, the constructor for it will be wrong, and
// slang will generate wrong code, the downstream compiler will fail to
// compile.

// CHECK: OpEntryPoint Fragment

struct PartlyDiffable : IDifferentiable
{
int i;
float q;
}


func breaker(x:PartlyDiffable.Differential) {
return;
}


[shader("fragment")]
float4 fragment(float4 in: SV_Position)
: SV_Target
{
if (PartlyDiffable.Differential(0).q == 0) {
return float4(0);
} else {
return float4(1);
}
}
Loading