| author | |
| committer | |
| log | 36df79cd3779b27a63f449618459603ce549660a |
| tree | 48b72df82c9f72a1151d1c5fc69ad8a09421a6cb |
| parent | febc7d3cd63eefe91c7aaa95e3a274a0b44e353e |
Generic parameter types are already ignored.2 files changed, 21 insertions(+), 1 deletions(-)
src/type.zig+3-1| ... | @@ -1036,7 +1036,9 @@ pub const Type = extern union { | ... | @@ -1036,7 +1036,9 @@ pub const Type = extern union { |
| 1036 | std.hash.autoHash(hasher, std.builtin.TypeId.Fn); | 1036 | std.hash.autoHash(hasher, std.builtin.TypeId.Fn); |
| 1037 | 1037 | ||
| 1038 | const fn_info = ty.fnInfo(); | 1038 | const fn_info = ty.fnInfo(); |
| 1039 | hashWithHasher(fn_info.return_type, hasher, mod); | 1039 | if (fn_info.return_type.tag() != .generic_poison) { |
| 1040 | hashWithHasher(fn_info.return_type, hasher, mod); | ||
| 1041 | } | ||
| 1040 | std.hash.autoHash(hasher, fn_info.alignment); | 1042 | std.hash.autoHash(hasher, fn_info.alignment); |
| 1041 | std.hash.autoHash(hasher, fn_info.cc); | 1043 | std.hash.autoHash(hasher, fn_info.cc); |
| 1042 | std.hash.autoHash(hasher, fn_info.is_var_args); | 1044 | std.hash.autoHash(hasher, fn_info.is_var_args); |
test/behavior/basic.zig+18| ... | @@ -987,3 +987,21 @@ test "array type comes from generic function" { | ... | @@ -987,3 +987,21 @@ test "array type comes from generic function" { |
| 987 | const args = [_]S.A(){.{}}; | 987 | const args = [_]S.A(){.{}}; |
| 988 | _ = args; | 988 | _ = args; |
| 989 | } | 989 | } |
| 990 | |||
| 991 | test "generic function uses return type of other generic function" { | ||
| 992 | if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO | ||
| 993 | |||
| 994 | const S = struct { | ||
| 995 | fn call( | ||
| 996 | f: anytype, | ||
| 997 | args: anytype, | ||
| 998 | ) @TypeOf(@call(.{}, f, @as(@TypeOf(args), undefined))) { | ||
| 999 | return @call(.{}, f, args); | ||
| 1000 | } | ||
| 1001 | |||
| 1002 | fn func(arg: anytype) @TypeOf(arg) { | ||
| 1003 | return arg; | ||
| 1004 | } | ||
| 1005 | }; | ||
| 1006 | try std.testing.expect(S.call(S.func, .{@as(u8, 1)}) == 1); | ||
| 1007 | } |