| author | |
| committer | |
| log | 3031d813874f6d6ad9ae4b793e3af6cdf632fa66 |
| tree | fa1880e43789f3f25db416be67821f3e00d058fc |
| parent | 5317d88414324c6555338e8574811c6710df4e44 |
| signature | Commit is signed but in an unrecognized format. |
Resolves: #200882 files changed, 19 insertions(+), 4 deletions(-)
src/Sema.zig+10-4| ... | ... | @@ -18145,10 +18145,16 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18145 | 18145 | |
| 18146 | 18146 | const ret_ty_opt = try pt.intern(.{ .opt = .{ |
| 18147 | 18147 | .ty = try pt.intern(.{ .opt_type = .type_type }), |
| 18148 | .val = if (func_ty_info.return_type == .generic_poison_type) | |
| 18149 | .none | |
| 18150 | else | |
| 18151 | func_ty_info.return_type, | |
| 18148 | .val = opt_val: { | |
| 18149 | const ret_ty: Type = .fromInterned(func_ty_info.return_type); | |
| 18150 | if (ret_ty.toIntern() == .generic_poison_type) break :opt_val .none; | |
| 18151 | if (ret_ty.zigTypeTag(zcu) == .error_union) { | |
| 18152 | if (ret_ty.errorUnionPayload(zcu).toIntern() == .generic_poison_type) { | |
| 18153 | break :opt_val .none; | |
| 18154 | } | |
| 18155 | } | |
| 18156 | break :opt_val ret_ty.toIntern(); | |
| 18157 | }, | |
| 18152 | 18158 | } }); |
| 18153 | 18159 | |
| 18154 | 18160 | const callconv_ty = try sema.getBuiltinType(src, .CallingConvention); |
test/behavior/type_info.zig+9| ... | ... | @@ -675,3 +675,12 @@ test "@typeInfo only contains pub decls" { |
| 675 | 675 | try std.testing.expectEqualStrings("Enum", decls[0].name); |
| 676 | 676 | try std.testing.expectEqualStrings("Struct", decls[1].name); |
| 677 | 677 | } |
| 678 | ||
| 679 | test "@typeInfo function with generic return type and inferred error set" { | |
| 680 | const S = struct { | |
| 681 | fn testFn(comptime T: type) !T {} | |
| 682 | }; | |
| 683 | ||
| 684 | const ret_ty = @typeInfo(@TypeOf(S.testFn)).@"fn".return_type; | |
| 685 | comptime assert(ret_ty == null); | |
| 686 | } |