| author | |
| committer | |
| log | 84000aa820de2d00571f7e8fde5d3973e2fdc441 |
| tree | f6bba6a2098749101eed7ba7a1fa21f8e23dab50 |
| parent | 8fa88c88c28420d89392a9984748070d35f18321 |
2 files changed, 13 insertions(+), 1 deletions(-)
src/Sema.zig+1-1| ... | ... | @@ -2526,7 +2526,7 @@ fn zirRetPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. |
| 2526 | 2526 | const src: LazySrcLoc = .{ .node_offset = inst_data }; |
| 2527 | 2527 | try sema.requireFunctionBlock(block, src); |
| 2528 | 2528 | |
| 2529 | if (block.is_comptime) { | |
| 2529 | if (block.is_comptime or try sema.typeRequiresComptime(block, src, sema.fn_ret_ty)) { | |
| 2530 | 2530 | const fn_ret_ty = try sema.resolveTypeFields(block, src, sema.fn_ret_ty); |
| 2531 | 2531 | return sema.analyzeComptimeAlloc(block, fn_ret_ty, 0, src); |
| 2532 | 2532 | } |
test/behavior/basic.zig+12| ... | ... | @@ -1074,3 +1074,15 @@ test "switch inside @as gets correct type" { |
| 1074 | 1074 | else => 0, |
| 1075 | 1075 | }); |
| 1076 | 1076 | } |
| 1077 | ||
| 1078 | test "inline call of function with a switch inside the return statement" { | |
| 1079 | const S = struct { | |
| 1080 | inline fn foo(x: anytype) @TypeOf(x) { | |
| 1081 | return switch (x) { | |
| 1082 | 1 => 1, | |
| 1083 | else => unreachable, | |
| 1084 | }; | |
| 1085 | } | |
| 1086 | }; | |
| 1087 | try expect(S.foo(1) == 1); | |
| 1088 | } |