summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bugs/generic-param-cast.slang37
-rw-r--r--tests/bugs/generic-param-cast.slang.expected.txt4
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/bugs/generic-param-cast.slang b/tests/bugs/generic-param-cast.slang
new file mode 100644
index 000000000..20b30a433
--- /dev/null
+++ b/tests/bugs/generic-param-cast.slang
@@ -0,0 +1,37 @@
+//TEST(smoke,compute):COMPARE_COMPUTE:-cpu -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+struct A<let I : int>
+{
+ int f() { return I; }
+};
+
+struct B<let U : uint>
+{
+ A<U> a;
+};
+
+int foo<let I : int>(A<I> a)
+{
+ return a.f();
+}
+
+int bar<let U : uint>(B<U> b)
+{
+ return foo(b.a);
+ // We previously were inferring the type at which to call `foo` as `U`
+ // instead of `int(U)`. This then cause the typechecker to impmediately
+ // fail because `U` does not unify with the type of `B<U>`'s `a` member,
+ // namely `int(U)`.
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ A<1> a;
+ B<1> b;
+ b.a = a;
+ outputBuffer[dispatchThreadID.x] = bar<1>(b);
+}
diff --git a/tests/bugs/generic-param-cast.slang.expected.txt b/tests/bugs/generic-param-cast.slang.expected.txt
new file mode 100644
index 000000000..98fb6a686
--- /dev/null
+++ b/tests/bugs/generic-param-cast.slang.expected.txt
@@ -0,0 +1,4 @@
+1
+1
+1
+1