authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-24 17:47:32+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-10-27 01:31:18+03:00
log9dcfc829e650bc9c0a89e9f7778744c774120c09
tree15fc28d037eb1064dcc1c5f52da930780a0a7cc3
parent4ac8ec4c5c80f6eca0ac7d7955c5486ef55ce042

Sema: fix some edge cases with error return traces and typeof blocks

Closes #13293

1 files changed, 7 insertions(+), 5 deletions(-)

src/Sema.zig+7-5
......@@ -5031,6 +5031,7 @@ fn zirBlock(sema: *Sema, parent_block: *Block, inst: Zir.Inst.Index) CompileErro
50315031 .label = &label,
50325032 .inlining = parent_block.inlining,
50335033 .is_comptime = parent_block.is_comptime,
5034 .is_typeof = parent_block.is_typeof,
50345035 .want_safety = parent_block.want_safety,
50355036 .float_mode = parent_block.float_mode,
50365037 .runtime_cond = parent_block.runtime_cond,
......@@ -5923,7 +5924,7 @@ fn zirCall(
59235924
59245925 const backend_supports_error_return_tracing = sema.mod.comp.bin_file.options.use_llvm;
59255926 if (backend_supports_error_return_tracing and sema.mod.comp.bin_file.options.error_return_tracing and
5926 !block.is_comptime and (input_is_error or pop_error_return_trace))
5927 !block.is_comptime and !block.is_typeof and (input_is_error or pop_error_return_trace))
59275928 {
59285929 const call_inst: Air.Inst.Ref = if (modifier == .always_tail) undefined else b: {
59295930 break :b try sema.analyzeCall(block, func, func_src, call_src, modifier, ensure_result_used, resolved_args, bound_arg_src);
......@@ -6403,7 +6404,7 @@ fn analyzeCall(
64036404 }
64046405
64056406 const new_func_resolved_ty = try Type.Tag.function.create(sema.arena, new_fn_info);
6406 if (!is_comptime_call) {
6407 if (!is_comptime_call and !block.is_typeof) {
64076408 try sema.emitDbgInline(block, parent_func.?, module_fn, new_func_resolved_ty, .dbg_inline_begin);
64086409
64096410 const zir_tags = sema.code.instructions.items(.tag);
......@@ -6441,7 +6442,7 @@ fn analyzeCall(
64416442 break :result try sema.analyzeBlockBody(block, call_src, &child_block, merges);
64426443 };
64436444
6444 if (!is_comptime_call and sema.typeOf(result).zigTypeTag() != .NoReturn) {
6445 if (!is_comptime_call and !block.is_typeof and sema.typeOf(result).zigTypeTag() != .NoReturn) {
64456446 try sema.emitDbgInline(
64466447 block,
64476448 module_fn,
......@@ -10210,6 +10211,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1021010211 .label = &label,
1021110212 .inlining = block.inlining,
1021210213 .is_comptime = block.is_comptime,
10214 .is_typeof = block.is_typeof,
1021310215 .switch_else_err_ty = else_error_ty,
1021410216 .runtime_cond = block.runtime_cond,
1021510217 .runtime_loop = block.runtime_loop,
......@@ -16401,7 +16403,7 @@ fn zirSaveErrRetIndex(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileE
1640116403 if (!ok) return;
1640216404
1640316405 // This is only relevant at runtime.
16404 if (block.is_comptime) return;
16406 if (block.is_comptime or block.is_typeof) return;
1640516407
1640616408 // This is only relevant within functions.
1640716409 if (sema.func == null) return;
......@@ -16421,7 +16423,7 @@ fn zirRestoreErrRetIndex(sema: *Sema, start_block: *Block, inst: Zir.Inst.Index)
1642116423 const src = sema.src; // TODO
1642216424
1642316425 // This is only relevant at runtime.
16424 if (start_block.is_comptime) return;
16426 if (start_block.is_comptime or start_block.is_typeof) return;
1642516427
1642616428 const backend_supports_error_return_tracing = sema.mod.comp.bin_file.options.use_llvm;
1642716429 const ok = sema.owner_func.?.calls_or_awaits_errorable_fn and