authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-04-23 14:48:16+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-05-16 17:42:51-07:00
loge369752430a1b3a50e57e11b9f0682d026c62feb
tree7538801877166bc4dddf9fbe7deab9ec54f868e3
parent53a5aee3b3684a03c91236702c9304dce21279e2

Sema: do not call `returnError` when returning payload of error union


3 files changed, 3 insertions(+), 5 deletions(-)

src/Module.zig+1-1
......@@ -4839,7 +4839,7 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air {
48394839 };
48404840 defer sema.deinit();
48414841
4842 // reset in case case calls to errorable functions are removed.
4842 // reset in case calls to errorable functions are removed.
48434843 func.calls_or_awaits_errorable_fn = false;
48444844
48454845 // First few indexes of extra are reserved and set at the end.
src/Sema.zig+2-1
......@@ -12658,7 +12658,8 @@ fn analyzeRet(
1265812658 const backend_supports_error_return_tracing =
1265912659 sema.mod.comp.bin_file.options.use_llvm;
1266012660
12661 if (sema.fn_ret_ty.isError() and sema.mod.comp.bin_file.options.error_return_tracing and
12661 if ((sema.fn_ret_ty.zigTypeTag() == .ErrorSet or sema.typeOf(uncasted_operand).zigTypeTag() == .ErrorUnion) and
12662 sema.mod.comp.bin_file.options.error_return_tracing and
1266212663 backend_supports_error_return_tracing)
1266312664 {
1266412665 const return_err_fn = try sema.getBuiltin(block, src, "returnError");
src/codegen/llvm.zig-3
......@@ -698,9 +698,6 @@ pub const Object = struct {
698698
699699 const lexical_block = dib.createLexicalBlock(subprogram.toScope(), di_file.?, line_number, 1);
700700 di_scope = lexical_block.toScope();
701
702 // Setup a debug location in case there is a call to `returnError` before a `.dbg_stmt`.
703 builder.setCurrentDebugLocation(line_number + func.lbrace_line, func.lbrace_column, di_scope.?, null);
704701 }
705702
706703 var fg: FuncGen = .{