diff options
| author | Veikka Tuominen <git@vexu.eu> | 2022-04-23 14:48:16 +0300 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-05-16 17:42:51 -0700 |
| commit | e369752430a1b3a50e57e11b9f0682d026c62feb (patch) | |
| tree | 7538801877166bc4dddf9fbe7deab9ec54f868e3 /src | |
| parent | 53a5aee3b3684a03c91236702c9304dce21279e2 (diff) | |
| download | zig-e369752430a1b3a50e57e11b9f0682d026c62feb.tar.gz zig-e369752430a1b3a50e57e11b9f0682d026c62feb.zip | |
Sema: do not call `returnError` when returning payload of error union
Diffstat (limited to 'src')
| -rw-r--r-- | src/Module.zig | 2 | ||||
| -rw-r--r-- | src/Sema.zig | 3 | ||||
| -rw-r--r-- | src/codegen/llvm.zig | 3 |
3 files changed, 3 insertions, 5 deletions
diff --git a/src/Module.zig b/src/Module.zig index cb38ddba45..11549ccda6 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4839,7 +4839,7 @@ pub fn analyzeFnBody(mod: *Module, func: *Fn, arena: Allocator) SemaError!Air { }; defer sema.deinit(); - // reset in case case calls to errorable functions are removed. + // reset in case calls to errorable functions are removed. func.calls_or_awaits_errorable_fn = false; // First few indexes of extra are reserved and set at the end. diff --git a/src/Sema.zig b/src/Sema.zig index 86f06c3ad3..a7dd905dd6 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -12658,7 +12658,8 @@ fn analyzeRet( const backend_supports_error_return_tracing = sema.mod.comp.bin_file.options.use_llvm; - if (sema.fn_ret_ty.isError() and sema.mod.comp.bin_file.options.error_return_tracing and + if ((sema.fn_ret_ty.zigTypeTag() == .ErrorSet or sema.typeOf(uncasted_operand).zigTypeTag() == .ErrorUnion) and + sema.mod.comp.bin_file.options.error_return_tracing and backend_supports_error_return_tracing) { const return_err_fn = try sema.getBuiltin(block, src, "returnError"); diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 9998f1d40f..dfb0f8f03b 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -698,9 +698,6 @@ pub const Object = struct { const lexical_block = dib.createLexicalBlock(subprogram.toScope(), di_file.?, line_number, 1); di_scope = lexical_block.toScope(); - - // Setup a debug location in case there is a call to `returnError` before a `.dbg_stmt`. - builder.setCurrentDebugLocation(line_number + func.lbrace_line, func.lbrace_column, di_scope.?, null); } var fg: FuncGen = .{ |
