aboutsummaryrefslogtreecommitdiff
path: root/test/behavior
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-08-24 19:52:52 +0300
committerVeikka Tuominen <git@vexu.eu>2022-08-24 21:31:02 +0300
commitcd1833044ab7505bc101c85f59889bd3ea3fac80 (patch)
treed7958e47cab0b196cc2d731b74938343619a188c /test/behavior
parentd515d37934476365929401a0ba7e5639b09a648a (diff)
downloadzig-cd1833044ab7505bc101c85f59889bd3ea3fac80.tar.gz
zig-cd1833044ab7505bc101c85f59889bd3ea3fac80.zip
Sema: do not construct nested partial function types
Closes #12616
Diffstat (limited to 'test/behavior')
-rw-r--r--test/behavior/generics.zig15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/behavior/generics.zig b/test/behavior/generics.zig
index d930fb7d27..ba4bca0c1a 100644
--- a/test/behavior/generics.zig
+++ b/test/behavior/generics.zig
@@ -342,3 +342,18 @@ test "generic instantiation of tagged union with only one field" {
try expect(S.foo(.{ .s = "a" }) == 1);
try expect(S.foo(.{ .s = "ab" }) == 2);
}
+
+test "nested generic function" {
+ const S = struct {
+ fn foo(comptime T: type, callback: *const fn (user_data: T) anyerror!void, data: T) anyerror!void {
+ try callback(data);
+ }
+ fn bar(a: u32) anyerror!void {
+ try expect(a == 123);
+ }
+
+ fn g(_: *const fn (anytype) void) void {}
+ };
+ try expect(@typeInfo(@TypeOf(S.g)).Fn.is_generic);
+ try S.foo(u32, S.bar, 123);
+}