summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-08-07 08:10:02 -0700
committerGitHub <noreply@github.com>2025-08-07 15:10:02 +0000
commit7cd8130e1a3dbcca8746e0577fb8df3bf2975bf8 (patch)
tree6da2b411da34039c3d0ec0e06fadd0e13f8f4842 /tests
parent67a96920674d628f615532a302504544a45e8187 (diff)
Support `expand` on concrete tuple values. (#8106)
Closes #8061. Along with the fix, also enhanced coercion/overload resolution to filter candidates based on the target type, allowing `tests\language-feature\higher-order-functions\overloaded.slang` to pass.
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/higher-order-functions/overloaded.slang13
-rw-r--r--tests/language-feature/higher-order-functions/overloaded.slang.expected8
-rw-r--r--tests/language-feature/tuple/tuple-expand-call.slang26
3 files changed, 36 insertions, 11 deletions
diff --git a/tests/language-feature/higher-order-functions/overloaded.slang b/tests/language-feature/higher-order-functions/overloaded.slang
index ebbc6ed19..d3d495bc1 100644
--- a/tests/language-feature/higher-order-functions/overloaded.slang
+++ b/tests/language-feature/higher-order-functions/overloaded.slang
@@ -1,11 +1,11 @@
-//TEST:SIMPLE:
+//TEST:INTERPRET(filecheck=CHECK):
func foo(f : functype (float) -> int) -> int{
return f(0);
}
int bit<T>(T) {
- return 1;
+ return 10;
}
int bit<T, let N : int>(vector<T, N>) {
@@ -13,6 +13,13 @@ int bit<T, let N : int>(vector<T, N>) {
}
int zit() {
- // In an ideal world in this case we could infer that we want bit<T>
+ // even though foo is overloaded, we should still be able to infer that we want bit<T>
+ // based on the parameter (expected) type.
return foo(bit<float>);
}
+
+void main()
+{
+ // CHECK: 10
+ printf("%d\n", zit());
+} \ No newline at end of file
diff --git a/tests/language-feature/higher-order-functions/overloaded.slang.expected b/tests/language-feature/higher-order-functions/overloaded.slang.expected
deleted file mode 100644
index 3d02bf06f..000000000
--- a/tests/language-feature/higher-order-functions/overloaded.slang.expected
+++ /dev/null
@@ -1,8 +0,0 @@
-result code = -1
-standard error = {
-tests/language-feature/higher-order-functions/overloaded.slang(17): error 39999: passing overloaded functions to higher order functions is not supported
- return foo(bit<float>);
- ^
-}
-standard output = {
-}
diff --git a/tests/language-feature/tuple/tuple-expand-call.slang b/tests/language-feature/tuple/tuple-expand-call.slang
new file mode 100644
index 000000000..f2293f03f
--- /dev/null
+++ b/tests/language-feature/tuple/tuple-expand-call.slang
@@ -0,0 +1,26 @@
+//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -output-using-type
+
+//TEST_INPUT: set outputBuffer = out ubuffer(data=[0 0], stride=4)
+
+#lang 2026
+
+RWStructuredBuffer<int> outputBuffer;
+
+int f(int x, float y) { return x + int(y); }
+
+int g<each T>(expand each Tuple<expand each T> t)
+{
+ return countof(t);
+}
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ Tuple<expand each Tuple<int, float>> x = (2, 3.0f);
+
+ // CHECK: 2
+ outputBuffer[0] = g<int, float>(expand each x);
+
+ // CHECK: 5
+ outputBuffer[1] = f(expand each x);
+}