From 8b38fbf842a880e346fbccef29bc47d77260c751 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 9 Dec 2024 19:24:04 -0800 Subject: [PATCH] Create scope for synthesized property decl. --- source/slang/slang-check-decl.cpp | 4 +++- tests/bugs/dynamic-interface-property.slang | 24 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/bugs/dynamic-interface-property.slang diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp index eeb75e3fd1..4279980e0f 100644 --- a/source/slang/slang-check-decl.cpp +++ b/source/slang/slang-check-decl.cpp @@ -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(); + 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. diff --git a/tests/bugs/dynamic-interface-property.slang b/tests/bugs/dynamic-interface-property.slang new file mode 100644 index 0000000000..4243ce71b0 --- /dev/null +++ b/tests/bugs/dynamic-interface-property.slang @@ -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 inputBuffer; + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer outputBuffer; + +[NumThreads(1, 1, 1)] +void computeMain() +{ + // CHECK: 1 + outputBuffer[0] = inputBuffer[0].value; +}