summaryrefslogtreecommitdiffstats
path: root/tests/language-feature
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-01-17 14:43:31 -0800
committerGitHub <noreply@github.com>2025-01-17 14:43:31 -0800
commitd1a13a730406646029cedd018bb9806943209baa (patch)
tree93f609f80111b923810d627209eed41f68fcba4f /tests/language-feature
parentfc77070fdc9bfa599e8d66b21743778de3011e53 (diff)
Allow __subscript<T> syntax. (#6124)
* Allow __subscript<T> syntax. * Fix.
Diffstat (limited to 'tests/language-feature')
-rw-r--r--tests/language-feature/generics/generic-subscript.slang24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/language-feature/generics/generic-subscript.slang b/tests/language-feature/generics/generic-subscript.slang
new file mode 100644
index 000000000..87eec3045
--- /dev/null
+++ b/tests/language-feature/generics/generic-subscript.slang
@@ -0,0 +1,24 @@
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -output-using-type
+
+//TEST_INPUT: set output = out ubuffer(data=[0 0 0 0], stride=4)
+RWStructuredBuffer<float> output;
+
+struct Tx
+{
+ float x;
+ __subscript<I>(I index) -> float
+ where I:IInteger
+ {
+ get { return x + index.toInt(); }
+ set { x = newValue;}
+ }
+}
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ Tx obj;
+ obj[0] = 3.0;
+ // CHECK: 5.0
+ output[0] = obj[2];
+} \ No newline at end of file