From febc7d3cd63eefe91c7aaa95e3a274a0b44e353e Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Tue, 31 May 2022 16:21:36 +0300 Subject: Sema: take `dbg_stmt` into account in `zirResolveInferredAlloc` --- src/Sema.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Sema.zig') diff --git a/src/Sema.zig b/src/Sema.zig index 505810a158..ed8391a44d 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -2976,7 +2976,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com // Even though we reuse the constant instruction, we still remove it from the // block so that codegen does not see it. - block.instructions.shrinkRetainingCapacity(block.instructions.items.len - 3); + block.instructions.shrinkRetainingCapacity(search_index); sema.air_values.items[value_index] = try Value.Tag.decl_ref.create(sema.arena, new_decl_index); // if bitcast ty ref needs to be made const, make_ptr_const // ZIR handles it later, so we can just use the ty ref here. -- cgit v1.2.3 From 56608cbb3d5577d8931830fa02d3e2920925ceab Mon Sep 17 00:00:00 2001 From: Veikka Tuominen Date: Tue, 31 May 2022 17:14:37 +0300 Subject: Sema: do not add calls to `returnError` for comptime known non-error values --- src/Sema.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Sema.zig') diff --git a/src/Sema.zig b/src/Sema.zig index ed8391a44d..d4c49973a1 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -13011,10 +13011,13 @@ fn analyzeRet( const backend_supports_error_return_tracing = sema.mod.comp.bin_file.options.use_llvm; - if ((sema.fn_ret_ty.zigTypeTag() == .ErrorSet or sema.typeOf(uncasted_operand).zigTypeTag() == .ErrorUnion) and + if (sema.fn_ret_ty.isError() and sema.mod.comp.bin_file.options.error_return_tracing and backend_supports_error_return_tracing) - { + ret_err: { + if (try sema.resolveMaybeUndefVal(block, src, operand)) |ret_val| { + if (ret_val.tag() != .@"error") break :ret_err; + } const return_err_fn = try sema.getBuiltin(block, src, "returnError"); const unresolved_stack_trace_ty = try sema.getBuiltinType(block, src, "StackTrace"); const stack_trace_ty = try sema.resolveTypeFields(block, src, unresolved_stack_trace_ty); -- cgit v1.2.3