summaryrefslogtreecommitdiffstats
path: root/tests/language-feature/interfaces
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-12-30 23:39:07 -0800
committerGitHub <noreply@github.com>2024-12-30 23:39:07 -0800
commitcc1b96d91d8875bf727079d58fbf78af1135f505 (patch)
tree593a6aae09e2710390ac34fdeb84614872ac9d5f /tests/language-feature/interfaces
parent88e221bad60ce20087fe2f8a85d506be36a6e6ca (diff)
Check mismatching method parameter direction against interface declaration. (#5964)
Diffstat (limited to 'tests/language-feature/interfaces')
-rw-r--r--tests/language-feature/interfaces/argument-direction-mismatch.slang37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/language-feature/interfaces/argument-direction-mismatch.slang b/tests/language-feature/interfaces/argument-direction-mismatch.slang
new file mode 100644
index 000000000..cf9d99fdd
--- /dev/null
+++ b/tests/language-feature/interfaces/argument-direction-mismatch.slang
@@ -0,0 +1,37 @@
+//TEST:SIMPLE(filecheck=CHECK): -target spirv
+
+public interface ITest {
+ public void testIn(int a);
+ public void testOut(out int b);
+};
+
+public struct TestImpl : ITest {
+ // CHECK: ([[# @LINE + 1]]): error 38105
+ public void testIn(out int a) {
+ a = 5;
+ }
+ // CHECK: ([[# @LINE + 1]]): error 38105
+ public void testOut(int b) {
+ b = 6;
+ }
+}
+
+RWStructuredBuffer<int> output;
+
+void doSomething<T>(T data) where T : ITest {
+ int a = 516;
+ data.testIn(a);
+ int b = 687;
+ data.testOut(b);
+
+ output[0] = a;
+ output[1] = b;
+}
+
+[shader("compute")]
+[numthreads(1,1,1)]
+void computeMain()
+{
+ TestImpl data;
+ doSomething(data);
+} \ No newline at end of file