summaryrefslogtreecommitdiff
path: root/tests/bugs/optional-generic.slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-06-11 23:58:25 -0700
committerGitHub <noreply@github.com>2024-06-11 23:58:25 -0700
commit3fe4a77287345c303aeb985e24ee237f272e8eca (patch)
tree59d5096a8f0e42286f8db2fb72d04f3db82f166f /tests/bugs/optional-generic.slang
parent5da06d43bb0997455211ca56597c4302b09909ab (diff)
Fix crash when using optional type in a generic. (#4341)
Diffstat (limited to 'tests/bugs/optional-generic.slang')
-rw-r--r--tests/bugs/optional-generic.slang22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/bugs/optional-generic.slang b/tests/bugs/optional-generic.slang
new file mode 100644
index 000000000..16b466273
--- /dev/null
+++ b/tests/bugs/optional-generic.slang
@@ -0,0 +1,22 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-slang -compute
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF):-slang -compute -vk
+
+
+Optional<T> genFunc<T : IArithmetic>(T v)
+{
+ if (v is int)
+ return v;
+ return none;
+}
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name buffer
+
+RWStructuredBuffer<int> buffer;
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ // BUF: 2
+ buffer[0] = genFunc(2).value;
+}
+