diff options
| author | Yong He <yonghe@outlook.com> | 2025-05-16 10:42:11 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-16 10:42:11 -0700 |
| commit | 9dfd5244ad2953753535e82acd05e72e5ab2bc5f (patch) | |
| tree | 0f7c8a0bf4ea3dd25348e1d1ac8e5bfcfd8c9724 /tests | |
| parent | 1fd7b2296d8360c245a0c732e7f842876533f92a (diff) | |
Allow lambda exprs without captures to coerce to `functype`. (#7129)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/language-feature/lambda/coerce-failure.slang | 19 | ||||
| -rw-r--r-- | tests/language-feature/lambda/coerce-to-functype.slang | 13 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/language-feature/lambda/coerce-failure.slang b/tests/language-feature/lambda/coerce-failure.slang new file mode 100644 index 000000000..a5286611c --- /dev/null +++ b/tests/language-feature/lambda/coerce-failure.slang @@ -0,0 +1,19 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv + + +func test(f: functype(int, int)->float) -> float +{ + return f(2,3) + 10.0f; +} + + +[numthreads(1,1,1)] +void computeMain() +{ + int c = 2; + // CHECK: ([[# @LINE+1]]): error 30019 + let result = test((int x, int y)=> x + y + c); + + // CHECK: ([[# @LINE+1]]): error 30019 + let result1 = test((int x, float y) => x + y); +}
\ No newline at end of file diff --git a/tests/language-feature/lambda/coerce-to-functype.slang b/tests/language-feature/lambda/coerce-to-functype.slang new file mode 100644 index 000000000..9ec430def --- /dev/null +++ b/tests/language-feature/lambda/coerce-to-functype.slang @@ -0,0 +1,13 @@ +//TEST:INTERPRET(filecheck=CHECK): + +func test(f: functype(int, int)->float) -> float +{ + return f(2,3) + 10.0f; +} + +func main() +{ + let result = test((int x, int y)=>x+y); + // CHECK: 15.0 + printf("%f\n", result); +}
\ No newline at end of file |
