| author | |
| committer | |
| log | b7b905d227c0124778214f7a307be04b7086ea6a |
| tree | 315e50ccc6de51722770042967ba86e655e9fc71 |
| parent | e7d28344fa3ee81d6ad7ca5ce1f83d50d8502118 |
closes #7078 files changed, 21 insertions(+), 14 deletions(-)
lib/std/event/loop.zig+1-1| ... | @@ -1469,7 +1469,7 @@ pub const Loop = struct { | ... | @@ -1469,7 +1469,7 @@ pub const Loop = struct { |
| 1469 | .Cancelled => continue, | 1469 | .Cancelled => continue, |
| 1470 | } | 1470 | } |
| 1471 | if (overlapped) |o| break o; | 1471 | if (overlapped) |o| break o; |
| 1472 | } else unreachable; // TODO else unreachable should not be necessary | 1472 | }; |
| 1473 | const resume_node = @fieldParentPtr(ResumeNode, "overlapped", overlapped); | 1473 | const resume_node = @fieldParentPtr(ResumeNode, "overlapped", overlapped); |
| 1474 | const handle = resume_node.handle; | 1474 | const handle = resume_node.handle; |
| 1475 | const resume_node_id = resume_node.id; | 1475 | const resume_node_id = resume_node.id; |
lib/std/os.zig+1-1| ... | @@ -3621,7 +3621,7 @@ pub fn accept( | ... | @@ -3621,7 +3621,7 @@ pub fn accept( |
| 3621 | else => |err| return unexpectedErrno(err), | 3621 | else => |err| return unexpectedErrno(err), |
| 3622 | } | 3622 | } |
| 3623 | } | 3623 | } |
| 3624 | } else unreachable; | 3624 | }; |
| 3625 | 3625 | ||
| 3626 | if (!have_accept4) { | 3626 | if (!have_accept4) { |
| 3627 | try setSockFlags(accepted_sock, flags); | 3627 | try setSockFlags(accepted_sock, flags); |
lib/std/zig/render.zig+1-1| ... | @@ -2211,7 +2211,7 @@ fn renderAsm( | ... | @@ -2211,7 +2211,7 @@ fn renderAsm( |
| 2211 | }, | 2211 | }, |
| 2212 | else => unreachable, | 2212 | else => unreachable, |
| 2213 | } | 2213 | } |
| 2214 | } else unreachable; // TODO shouldn't need this on while(true) | 2214 | } |
| 2215 | } | 2215 | } |
| 2216 | 2216 | ||
| 2217 | fn renderCall( | 2217 | fn renderCall( |
lib/std/zig/string_literal.zig+1-1| ... | @@ -266,7 +266,7 @@ pub fn parseWrite(writer: anytype, bytes: []const u8) error{OutOfMemory}!Result | ... | @@ -266,7 +266,7 @@ pub fn parseWrite(writer: anytype, bytes: []const u8) error{OutOfMemory}!Result |
| 266 | index += 1; | 266 | index += 1; |
| 267 | }, | 267 | }, |
| 268 | } | 268 | } |
| 269 | } else unreachable; // TODO should not need else unreachable on while(true) | 269 | } |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | /// Higher level API. Does not return extra info about parse errors. | 272 | /// Higher level API. Does not return extra info about parse errors. |
src/Sema.zig+7-7| ... | @@ -1359,7 +1359,7 @@ fn analyzeBodyInner( | ... | @@ -1359,7 +1359,7 @@ fn analyzeBodyInner( |
| 1359 | break check_block.runtime_index; | 1359 | break check_block.runtime_index; |
| 1360 | } | 1360 | } |
| 1361 | check_block = check_block.parent.?; | 1361 | check_block = check_block.parent.?; |
| 1362 | } else unreachable; | 1362 | }; |
| 1363 | 1363 | ||
| 1364 | if (@enumToInt(target_runtime_index) < @enumToInt(block.runtime_index)) { | 1364 | if (@enumToInt(target_runtime_index) < @enumToInt(block.runtime_index)) { |
| 1365 | const runtime_src = block.runtime_cond orelse block.runtime_loop.?; | 1365 | const runtime_src = block.runtime_cond orelse block.runtime_loop.?; |
| ... | @@ -1733,7 +1733,7 @@ fn analyzeBodyInner( | ... | @@ -1733,7 +1733,7 @@ fn analyzeBodyInner( |
| 1733 | break always_noreturn; | 1733 | break always_noreturn; |
| 1734 | map.putAssumeCapacity(inst, air_inst); | 1734 | map.putAssumeCapacity(inst, air_inst); |
| 1735 | i += 1; | 1735 | i += 1; |
| 1736 | } else unreachable; | 1736 | }; |
| 1737 | 1737 | ||
| 1738 | // balance out dbg_block_begins in case of early noreturn | 1738 | // balance out dbg_block_begins in case of early noreturn |
| 1739 | const noreturn_inst = block.instructions.popOrNull(); | 1739 | const noreturn_inst = block.instructions.popOrNull(); |
| ... | @@ -3478,7 +3478,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro | ... | @@ -3478,7 +3478,7 @@ fn zirMakePtrConst(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileErro |
| 3478 | .store => break candidate, | 3478 | .store => break candidate, |
| 3479 | else => break :ct, | 3479 | else => break :ct, |
| 3480 | } | 3480 | } |
| 3481 | } else unreachable; // TODO shouldn't need this | 3481 | }; |
| 3482 | 3482 | ||
| 3483 | while (true) { | 3483 | while (true) { |
| 3484 | if (search_index == 0) break :ct; | 3484 | if (search_index == 0) break :ct; |
| ... | @@ -3704,7 +3704,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -3704,7 +3704,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3704 | .store => break candidate, | 3704 | .store => break candidate, |
| 3705 | else => break :ct, | 3705 | else => break :ct, |
| 3706 | } | 3706 | } |
| 3707 | } else unreachable; // TODO shouldn't need this | 3707 | }; |
| 3708 | 3708 | ||
| 3709 | const bitcast_inst = while (true) { | 3709 | const bitcast_inst = while (true) { |
| 3710 | if (search_index == 0) break :ct; | 3710 | if (search_index == 0) break :ct; |
| ... | @@ -3716,7 +3716,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -3716,7 +3716,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3716 | .bitcast => break candidate, | 3716 | .bitcast => break candidate, |
| 3717 | else => break :ct, | 3717 | else => break :ct, |
| 3718 | } | 3718 | } |
| 3719 | } else unreachable; // TODO shouldn't need this | 3719 | }; |
| 3720 | 3720 | ||
| 3721 | const const_inst = while (true) { | 3721 | const const_inst = while (true) { |
| 3722 | if (search_index == 0) break :ct; | 3722 | if (search_index == 0) break :ct; |
| ... | @@ -3728,7 +3728,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com | ... | @@ -3728,7 +3728,7 @@ fn zirResolveInferredAlloc(sema: *Sema, block: *Block, inst: Zir.Inst.Index) Com |
| 3728 | .constant => break candidate, | 3728 | .constant => break candidate, |
| 3729 | else => break :ct, | 3729 | else => break :ct, |
| 3730 | } | 3730 | } |
| 3731 | } else unreachable; // TODO shouldn't need this | 3731 | }; |
| 3732 | 3732 | ||
| 3733 | const store_op = air_datas[store_inst].bin_op; | 3733 | const store_op = air_datas[store_inst].bin_op; |
| 3734 | const store_val = (try sema.resolveMaybeUndefVal(store_op.rhs)) orelse break :ct; | 3734 | const store_val = (try sema.resolveMaybeUndefVal(store_op.rhs)) orelse break :ct; |
| ... | @@ -14964,7 +14964,7 @@ fn zirClosureGet( | ... | @@ -14964,7 +14964,7 @@ fn zirClosureGet( |
| 14964 | break tv; | 14964 | break tv; |
| 14965 | } | 14965 | } |
| 14966 | scope = scope.parent.?; | 14966 | scope = scope.parent.?; |
| 14967 | } else unreachable; | 14967 | }; |
| 14968 | 14968 | ||
| 14969 | if (tv.val.tag() == .unreachable_value and !block.is_typeof and sema.func == null) { | 14969 | if (tv.val.tag() == .unreachable_value and !block.is_typeof and sema.func == null) { |
| 14970 | const msg = msg: { | 14970 | const msg = msg: { |
src/print_air.zig+1-1| ... | @@ -848,7 +848,7 @@ const Writer = struct { | ... | @@ -848,7 +848,7 @@ const Writer = struct { |
| 848 | if ((bits >> 31) != 0) break :blk false; | 848 | if ((bits >> 31) != 0) break :blk false; |
| 849 | extra_index += 1; | 849 | extra_index += 1; |
| 850 | tomb_op_index += 31; | 850 | tomb_op_index += 31; |
| 851 | } else unreachable; | 851 | } |
| 852 | }; | 852 | }; |
| 853 | return w.writeInstRef(s, operand, dies); | 853 | return w.writeInstRef(s, operand, dies); |
| 854 | } | 854 | } |
src/translate_c.zig+2-2| ... | @@ -523,7 +523,7 @@ fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void { | ... | @@ -523,7 +523,7 @@ fn declVisitorNamesOnly(c: *Context, decl: *const clang.Decl) Error!void { |
| 523 | child_ty = macroqualified_ty.getModifiedType().getTypePtr(); | 523 | child_ty = macroqualified_ty.getModifiedType().getTypePtr(); |
| 524 | }, | 524 | }, |
| 525 | else => return, | 525 | else => return, |
| 526 | } else unreachable; | 526 | }; |
| 527 | 527 | ||
| 528 | const result = try c.unnamed_typedefs.getOrPut(c.gpa, addr); | 528 | const result = try c.unnamed_typedefs.getOrPut(c.gpa, addr); |
| 529 | if (result.found_existing) { | 529 | if (result.found_existing) { |
| ... | @@ -629,7 +629,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { | ... | @@ -629,7 +629,7 @@ fn visitFnDecl(c: *Context, fn_decl: *const clang.FunctionDecl) Error!void { |
| 629 | }, | 629 | }, |
| 630 | else => break fn_type, | 630 | else => break fn_type, |
| 631 | } | 631 | } |
| 632 | } else unreachable; | 632 | }; |
| 633 | const fn_ty = @ptrCast(*const clang.FunctionType, fn_type); | 633 | const fn_ty = @ptrCast(*const clang.FunctionType, fn_type); |
| 634 | const return_qt = fn_ty.getReturnType(); | 634 | const return_qt = fn_ty.getReturnType(); |
| 635 | 635 |
test/behavior/while.zig+7| ... | @@ -364,3 +364,10 @@ test "try terminating an infinite loop" { | ... | @@ -364,3 +364,10 @@ test "try terminating an infinite loop" { |
| 364 | _ = try Foo.bar(); | 364 | _ = try Foo.bar(); |
| 365 | } else unreachable); | 365 | } else unreachable); |
| 366 | } | 366 | } |
| 367 | |||
| 368 | test "while loop with comptime true condition needs no else block to return value with break" { | ||
| 369 | const x = while (true) { | ||
| 370 | break @as(u32, 69); | ||
| 371 | }; | ||
| 372 | try expect(x == 69); | ||
| 373 | } |