mirror of
https://github.com/ziglang/zig.git
synced 2025-01-05 18:00:25 +00:00
parent
ccea8dcbf6
commit
716b0b8655
@ -4664,7 +4664,7 @@ void render_const_value(CodeGen *g, Buf *buf, ConstExprValue *const_val) {
|
||||
buf_appendf(buf, "%s", buf_ptr(&const_val->data.x_type->name));
|
||||
return;
|
||||
case TypeTableEntryIdUnreachable:
|
||||
buf_appendf(buf, "@unreachable()");
|
||||
buf_appendf(buf, "unreachable");
|
||||
return;
|
||||
case TypeTableEntryIdBool:
|
||||
{
|
||||
|
@ -11154,8 +11154,8 @@ static TypeTableEntry *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionP
|
||||
}
|
||||
|
||||
if (new_incoming_blocks.length == 0) {
|
||||
ir_build_const_from(ira, &phi_instruction->base);
|
||||
return ira->codegen->builtin_types.entry_void;
|
||||
ir_build_unreachable_from(&ira->new_irb, &phi_instruction->base);
|
||||
return ir_finish_anal(ira, ira->codegen->builtin_types.entry_unreachable);
|
||||
}
|
||||
|
||||
if (new_incoming_blocks.length == 1) {
|
||||
|
@ -224,3 +224,14 @@ fn switchWithUnreachable(x: i32) -> i32 {
|
||||
}
|
||||
return 10;
|
||||
}
|
||||
|
||||
fn return_a_number() -> %i32 {
|
||||
return 1;
|
||||
}
|
||||
|
||||
test "capture value of switch with all unreachable prongs" {
|
||||
const x = return_a_number() %% |err| switch (err) {
|
||||
else => unreachable,
|
||||
};
|
||||
assert(x == 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user