File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -1036,7 +1036,9 @@ pub const Type = extern union {
1036
1036
std .hash .autoHash (hasher , std .builtin .TypeId .Fn );
1037
1037
1038
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
1042
std .hash .autoHash (hasher , fn_info .alignment );
1041
1043
std .hash .autoHash (hasher , fn_info .cc );
1042
1044
std .hash .autoHash (hasher , fn_info .is_var_args );
Original file line number Diff line number Diff line change @@ -987,3 +987,21 @@ test "array type comes from generic function" {
987
987
const args = [_ ]S .A (){.{}};
988
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
+ }
You can’t perform that action at this time.
0 commit comments