zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit cd992b89d2252fade1e56b5e4e7537b171af890e (tree)
parent a665872e881920e8020a513340d2427b88a55bd6
Author: Andrew Kelley <superjoe30@gmail.com>
Date:   Fri, 24 Feb 2017 15:07:46 -0500

fix unwrap error payload not emitting debug safety

Diffstat:
Msrc/ir.cpp | 2+-
Mtest/run_tests.cpp | 14++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/ir.cpp b/src/ir.cpp @@ -12423,6 +12423,7 @@ bool ir_has_side_effects(IrInstruction *instruction) { case IrInstructionIdCheckSwitchProngs: case IrInstructionIdSetGlobalAlign: case IrInstructionIdSetGlobalSection: + case IrInstructionIdUnwrapErrPayload: return true; case IrInstructionIdPhi: case IrInstructionIdUnOp: @@ -12471,7 +12472,6 @@ bool ir_has_side_effects(IrInstruction *instruction) { case IrInstructionIdFrameAddress: case IrInstructionIdTestErr: case IrInstructionIdUnwrapErrCode: - case IrInstructionIdUnwrapErrPayload: case IrInstructionIdMaybeWrap: case IrInstructionIdErrWrapCode: case IrInstructionIdErrWrapPayload: diff --git a/test/run_tests.cpp b/test/run_tests.cpp @@ -1896,6 +1896,20 @@ fn unsigned_cast(x: i32) -> u32 { } )SOURCE"); + add_debug_safety_case("unwrap error", R"SOURCE( +pub fn panic(message: []const u8) -> unreachable { + @breakpoint(); + while (true) {} +} +error Whatever; +pub fn main(args: [][]u8) -> %void { + %%bar(); +} +fn bar() -> %void { + return error.Whatever; +} + )SOURCE"); + } //////////////////////////////////////////////////////////////////////////////