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 {...@@ -4839,7 +4839,7 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air {
4839 };4839 };
4840 defer sema.deinit();4840 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.
4843 func.calls_or_awaits_errorable_fn = false;4843 func.calls_or_awaits_errorable_fn = false;
48444844
4845 // First few indexes of extra are reserved and set at the end.4845 // First few indexes of extra are reserved and set at the end.
src/Sema.zig+2-1
...@@ -12658,7 +12658,8 @@ fn analyzeRet(...@@ -12658,7 +12658,8 @@ fn analyzeRet(
12658 const backend_supports_error_return_tracing =12658 const backend_supports_error_return_tracing =
12659 sema.mod.comp.bin_file.options.use_llvm;12659 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 and12661 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
12662 backend_supports_error_return_tracing)12663 backend_supports_error_return_tracing)
12663 {12664 {
12664 const return_err_fn = try sema.getBuiltin(block, src, "returnError");12665 const return_err_fn = try sema.getBuiltin(block, src, "returnError");
src/codegen/llvm.zig-3
...@@ -698,9 +698,6 @@ pub const Object = struct {...@@ -698,9 +698,6 @@ pub const Object = struct {
698698
699 const lexical_block = dib.createLexicalBlock(subprogram.toScope(), di_file.?, line_number, 1);699 const lexical_block = dib.createLexicalBlock(subprogram.toScope(), di_file.?, line_number, 1);
700 di_scope = lexical_block.toScope();700 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);
704 }701 }
705702
706 var fg: FuncGen = .{703 var fg: FuncGen = .{