Skip to content

Commit

Permalink
Create scope for synthesized property decl. (#5817)
Browse files Browse the repository at this point in the history
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
  • Loading branch information
csyonghe and expipiplus1 authored Dec 10, 2024
1 parent 89bf795 commit 8bf4743
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/slang/slang-check-decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5070,7 +5070,9 @@ bool SemanticsVisitor::trySynthesizePropertyRequirementWitness(
synPropertyDecl->nameAndLoc.name =
getName(String("$syn_property_") + getText(requiredMemberDeclRef.getName()));
synPropertyDecl->parentDecl = context->parentDecl;

synPropertyDecl->ownedScope = m_astBuilder->create<Scope>();
synPropertyDecl->ownedScope->containerDecl = synPropertyDecl;
synPropertyDecl->ownedScope->parent = context->parentDecl->ownedScope;

// The type of our synthesized property can be derived from the
// specialized declref to the requirement decl.
Expand Down
24 changes: 24 additions & 0 deletions tests/bugs/dynamic-interface-property.slang
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK):-output-using-type

public interface ITest {
property int value;
};

struct Test : ITest {
int value;
};

//TEST_INPUT: type_conformance Test:ITest = 1;

//TEST_INPUT: set inputBuffer = ubuffer(data=[0 0 1 0 1 0 0 0], stride=4)
RWStructuredBuffer<ITest> inputBuffer;

//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;

[NumThreads(1, 1, 1)]
void computeMain()
{
// CHECK: 1
outputBuffer[0] = inputBuffer[0].value;
}

0 comments on commit 8bf4743

Please sign in to comment.