-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix inccorect dropping of declref during Unification of DeclaredSubty…
…peWitness. (#5041) * Fix inccorect dropping of declref during Unification of DeclaredSubtypeWitness. * Add extension test.
- Loading branch information
Showing
3 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
tests/language-feature/generics/nested-gen-value-param-inference-2.slang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type | ||
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type | ||
|
||
interface IValueGeneric<let D : int> {} | ||
struct ValGenericImpl<let D : int> : IValueGeneric<D> {} | ||
|
||
struct NestedValueGeneric<let D : int, S : IValueGeneric<D>> | ||
{ | ||
int x; | ||
} | ||
|
||
void acceptor<let D : int, S : IValueGeneric<D>>(NestedValueGeneric<D, S> x) | ||
{ | ||
outputBuffer[0] = D + x.x; | ||
} | ||
|
||
extension<let D : int, S : IValueGeneric<D>> NestedValueGeneric<D, S> | ||
{ | ||
void foo() | ||
{ | ||
acceptor(this); | ||
} | ||
} | ||
void test2(NestedValueGeneric<2, ValGenericImpl<2>> x) | ||
{ | ||
// 'foo' should be a member of 'NestedValueGeneric<2, ValGenericImpl<2>>' through | ||
// the extension above. | ||
x.foo(); | ||
} | ||
|
||
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer | ||
RWStructuredBuffer<int> outputBuffer; | ||
|
||
[numthreads(1, 1, 1)] | ||
void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) | ||
{ | ||
NestedValueGeneric<2, ValGenericImpl<2>> x; | ||
x.x = 1; | ||
test2(x); | ||
// CHECK: 3 | ||
} |
32 changes: 32 additions & 0 deletions
32
tests/language-feature/generics/nested-gen-value-param-inference.slang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-slang -compute -shaderobj -output-using-type | ||
//TEST(compute, vulkan):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-vk -compute -shaderobj -output-using-type | ||
|
||
interface IValueGeneric<let D : int> {} | ||
struct ValGenericImpl<let D : int> : IValueGeneric<D> {} | ||
|
||
struct NestedValueGeneric<let D : int, S : IValueGeneric<D>> | ||
{ | ||
int x; | ||
} | ||
|
||
void acceptor<let D : int, S : IValueGeneric<D>>(NestedValueGeneric<D, S> x) | ||
{ | ||
outputBuffer[0] = D + x.x; | ||
} | ||
void test(NestedValueGeneric<2, ValGenericImpl<2>> x) | ||
{ | ||
// Test that we can correctly infer acceptor.D and acceptor.S from `x`. | ||
acceptor(x); | ||
} | ||
|
||
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer | ||
RWStructuredBuffer<int> outputBuffer; | ||
|
||
[numthreads(1, 1, 1)] | ||
void computeMain(int3 dispatchThreadID: SV_DispatchThreadID) | ||
{ | ||
NestedValueGeneric<2, ValGenericImpl<2>> x; | ||
x.x = 1; | ||
test(x); | ||
// CHECK: 3 | ||
} |