| author | |
| committer | |
| log | 451ce090674d6d5f2c23e6667047e1e479917c93 |
| tree | cbe8722f059086fdf30a76ce94d1ac16086dacd5 |
| parent | 22e6bfca9602fdb79f669b494fa7f1c58094706c |
* `noreturn` is the primitive type.
* `unreachable` is a control flow keyword.
* `@unreachable()` builtin function is deleted.
closes #21435 files changed, 130 insertions(+), 192 deletions(-)
doc/langref.md+1-84| ... | ... | @@ -155,7 +155,7 @@ GotoExpression = "goto" Symbol |
| 155 | 155 | |
| 156 | 156 | GroupedExpression = "(" Expression ")" |
| 157 | 157 | |
| 158 | KeywordLiteral = "true" | "false" | "null" | "break" | "continue" | "undefined" | "error" | "type" | "this" | |
| 158 | KeywordLiteral = "true" | "false" | "null" | "break" | "continue" | "undefined" | "error" | "type" | "this" | "unreachable" | |
| 159 | 159 | |
| 160 | 160 | ContainerDecl = option("extern" | "packed") ("struct" | "enum" | "union") "{" many(ContainerMember) "}" |
| 161 | 161 | |
| ... | ... | @@ -213,60 +213,6 @@ f32 float 32-bit floating point |
| 213 | 213 | f64 double 64-bit floating point |
| 214 | 214 | ``` |
| 215 | 215 | |
| 216 | ### Boolean Type | |
| 217 | ||
| 218 | The boolean type has the name `bool` and represents either true or false. | |
| 219 | ||
| 220 | ### Function Type | |
| 221 | ||
| 222 | TODO | |
| 223 | ||
| 224 | ### Fixed-Size Array Type | |
| 225 | ||
| 226 | Example: The string `"aoeu"` has type `[4]u8`. | |
| 227 | ||
| 228 | The size is known at compile time and is part of the type. | |
| 229 | ||
| 230 | ### Slice Type | |
| 231 | ||
| 232 | A slice can be obtained with the slicing syntax: `array[start...end]` | |
| 233 | ||
| 234 | Example: `"aoeu"[0...2]` has type `[]u8`. | |
| 235 | ||
| 236 | ### Struct Type | |
| 237 | ||
| 238 | TODO | |
| 239 | ||
| 240 | ### Enum Type | |
| 241 | ||
| 242 | TODO | |
| 243 | ||
| 244 | ### Maybe Type | |
| 245 | ||
| 246 | TODO | |
| 247 | ||
| 248 | ### Pure Error Type | |
| 249 | ||
| 250 | TODO | |
| 251 | ||
| 252 | ### Error Union Type | |
| 253 | ||
| 254 | TODO | |
| 255 | ||
| 256 | ### Pointer Type | |
| 257 | ||
| 258 | TODO | |
| 259 | ||
| 260 | ### Unreachable Type | |
| 261 | ||
| 262 | The unreachable type has the name `unreachable`. TODO explanation | |
| 263 | ||
| 264 | ### Void Type | |
| 265 | ||
| 266 | The void type has the name `void`. void types are zero bits and are omitted | |
| 267 | from codegen. | |
| 268 | ||
| 269 | ||
| 270 | 216 | ## Expressions |
| 271 | 217 | |
| 272 | 218 | ### Literals |
| ... | ... | @@ -347,31 +293,6 @@ has a terminating null byte. |
| 347 | 293 | Floating point | 123.0E+77 | Optional |
| 348 | 294 | Hex floating point | 0x103.70p-5 | Optional |
| 349 | 295 | |
| 350 | ### Identifiers | |
| 351 | ||
| 352 | TODO | |
| 353 | ||
| 354 | ### Declarations | |
| 355 | ||
| 356 | Declarations have type `void`. | |
| 357 | ||
| 358 | #### Function Declarations | |
| 359 | ||
| 360 | TODO | |
| 361 | ||
| 362 | #### Variable Declarations | |
| 363 | ||
| 364 | TODO | |
| 365 | ||
| 366 | #### Struct Declarations | |
| 367 | ||
| 368 | TODO | |
| 369 | ||
| 370 | #### Enum Declarations | |
| 371 | ||
| 372 | TODO | |
| 373 | ||
| 374 | ||
| 375 | 296 | ## Built-in Functions |
| 376 | 297 | |
| 377 | 298 | Built-in functions are prefixed with `@`. Remember that the `comptime` keyword on |
| ... | ... | @@ -682,10 +603,6 @@ code. |
| 682 | 603 | |
| 683 | 604 | This function returns an integer type with the given signness and bit count. |
| 684 | 605 | |
| 685 | ### @setFnTest(func) | |
| 686 | ||
| 687 | Makes the target function a test function. | |
| 688 | ||
| 689 | 606 | ### @setDebugSafety(scope, safety_on: bool) |
| 690 | 607 | |
| 691 | 608 | Sets a whether we want debug safety checks on for a given scope. |
doc/vim/syntax/zig.vim+1-1| ... | ... | @@ -16,7 +16,7 @@ syn keyword zigRepeat while for |
| 16 | 16 | |
| 17 | 17 | syn keyword zigConstant null undefined this |
| 18 | 18 | syn keyword zigKeyword fn use test |
| 19 | syn keyword zigType bool f32 f64 void Unreachable type error | |
| 19 | syn keyword zigType bool f32 f64 void noreturn type error | |
| 20 | 20 | syn keyword zigType i8 u8 i16 u16 i32 u32 i64 u64 isize usize |
| 21 | 21 | syn keyword zigType c_short c_ushort c_int c_uint c_long c_ulong c_longlong c_ulonglong c_long_double |
| 22 | 22 |
src/all_types.hpp+5-1| ... | ... | @@ -334,6 +334,7 @@ enum NodeType { |
| 334 | 334 | NodeTypeNullLiteral, |
| 335 | 335 | NodeTypeUndefinedLiteral, |
| 336 | 336 | NodeTypeThisLiteral, |
| 337 | NodeTypeUnreachable, | |
| 337 | 338 | NodeTypeIfBoolExpr, |
| 338 | 339 | NodeTypeIfVarExpr, |
| 339 | 340 | NodeTypeWhileExpr, |
| ... | ... | @@ -758,6 +759,9 @@ struct AstNodeBreakExpr { |
| 758 | 759 | |
| 759 | 760 | struct AstNodeContinueExpr { |
| 760 | 761 | }; |
| 762 | struct AstNodeUnreachableExpr { | |
| 763 | }; | |
| 764 | ||
| 761 | 765 | |
| 762 | 766 | struct AstNodeArrayType { |
| 763 | 767 | AstNode *size; |
| ... | ... | @@ -827,6 +831,7 @@ struct AstNode { |
| 827 | 831 | AstNodeBoolLiteral bool_literal; |
| 828 | 832 | AstNodeBreakExpr break_expr; |
| 829 | 833 | AstNodeContinueExpr continue_expr; |
| 834 | AstNodeUnreachableExpr unreachable_expr; | |
| 830 | 835 | AstNodeArrayType array_type; |
| 831 | 836 | AstNodeErrorType error_type; |
| 832 | 837 | AstNodeTypeLiteral type_literal; |
| ... | ... | @@ -1173,7 +1178,6 @@ enum BuiltinFnId { |
| 1173 | 1178 | BuiltinFnIdDivExact, |
| 1174 | 1179 | BuiltinFnIdTruncate, |
| 1175 | 1180 | BuiltinFnIdIntType, |
| 1176 | BuiltinFnIdUnreachable, | |
| 1177 | 1181 | BuiltinFnIdSetFnVisible, |
| 1178 | 1182 | BuiltinFnIdSetDebugSafety, |
| 1179 | 1183 | BuiltinFnIdAlloca, |
src/analyze.cpp+1| ... | ... | @@ -2110,6 +2110,7 @@ void scan_decls(CodeGen *g, ScopeDecls *decls_scope, AstNode *node) { |
| 2110 | 2110 | case NodeTypeGoto: |
| 2111 | 2111 | case NodeTypeBreak: |
| 2112 | 2112 | case NodeTypeContinue: |
| 2113 | case NodeTypeUnreachable: | |
| 2113 | 2114 | case NodeTypeAsmExpr: |
| 2114 | 2115 | case NodeTypeFieldAccessExpr: |
| 2115 | 2116 | case NodeTypeStructField: |
src/ast_render.cpp+7| ... | ... | @@ -216,6 +216,8 @@ static const char *node_type_str(NodeType node_type) { |
| 216 | 216 | return "Break"; |
| 217 | 217 | case NodeTypeContinue: |
| 218 | 218 | return "Continue"; |
| 219 | case NodeTypeUnreachable: | |
| 220 | return "Unreachable"; | |
| 219 | 221 | case NodeTypeAsmExpr: |
| 220 | 222 | return "AsmExpr"; |
| 221 | 223 | case NodeTypeFieldAccessExpr: |
| ... | ... | @@ -890,6 +892,11 @@ static void render_node_extra(AstRender *ar, AstNode *node, bool grouped) { |
| 890 | 892 | fprintf(ar->f, "continue"); |
| 891 | 893 | break; |
| 892 | 894 | } |
| 895 | case NodeTypeUnreachable: | |
| 896 | { | |
| 897 | fprintf(ar->f, "unreachable"); | |
| 898 | break; | |
| 899 | } | |
| 893 | 900 | case NodeTypeSliceExpr: |
| 894 | 901 | { |
| 895 | 902 | render_node_ungrouped(ar, node->data.slice_expr.array_ref_expr); |
src/codegen.cpp+1-2| ... | ... | @@ -3786,7 +3786,7 @@ static void define_builtin_types(CodeGen *g) { |
| 3786 | 3786 | TypeTableEntry *entry = new_type_table_entry(TypeTableEntryIdUnreachable); |
| 3787 | 3787 | entry->type_ref = LLVMVoidType(); |
| 3788 | 3788 | entry->zero_bits = true; |
| 3789 | buf_init_from_str(&entry->name, "unreachable"); | |
| 3789 | buf_init_from_str(&entry->name, "noreturn"); | |
| 3790 | 3790 | entry->di_type = g->builtin_types.entry_void->di_type; |
| 3791 | 3791 | g->builtin_types.entry_unreachable = entry; |
| 3792 | 3792 | g->primitive_type_table.put(&entry->name, entry); |
| ... | ... | @@ -4096,7 +4096,6 @@ static void define_builtin_fns(CodeGen *g) { |
| 4096 | 4096 | create_builtin_fn(g, BuiltinFnIdCompileErr, "compileError", 1); |
| 4097 | 4097 | create_builtin_fn(g, BuiltinFnIdCompileLog, "compileLog", SIZE_MAX); |
| 4098 | 4098 | create_builtin_fn(g, BuiltinFnIdIntType, "intType", 2); |
| 4099 | create_builtin_fn(g, BuiltinFnIdUnreachable, "unreachable", 0); | |
| 4100 | 4099 | create_builtin_fn(g, BuiltinFnIdSetFnVisible, "setFnVisible", 2); |
| 4101 | 4100 | create_builtin_fn(g, BuiltinFnIdSetDebugSafety, "setDebugSafety", 2); |
| 4102 | 4101 | create_builtin_fn(g, BuiltinFnIdAlloca, "alloca", 2); |
src/ir.cpp+2-2| ... | ... | @@ -3751,8 +3751,6 @@ static IrInstruction *ir_gen_builtin_fn_call(IrBuilder *irb, Scope *scope, AstNo |
| 3751 | 3751 | switch (builtin_fn->id) { |
| 3752 | 3752 | case BuiltinFnIdInvalid: |
| 3753 | 3753 | zig_unreachable(); |
| 3754 | case BuiltinFnIdUnreachable: | |
| 3755 | return ir_build_unreachable(irb, scope, node); | |
| 3756 | 3754 | case BuiltinFnIdTypeof: |
| 3757 | 3755 | { |
| 3758 | 3756 | AstNode *arg_node = node->data.fn_call_expr.params.at(0); |
| ... | ... | @@ -5467,6 +5465,8 @@ static IrInstruction *ir_gen_node_raw(IrBuilder *irb, AstNode *node, Scope *scop |
| 5467 | 5465 | return ir_lval_wrap(irb, scope, ir_gen_break(irb, scope, node), lval); |
| 5468 | 5466 | case NodeTypeContinue: |
| 5469 | 5467 | return ir_lval_wrap(irb, scope, ir_gen_continue(irb, scope, node), lval); |
| 5468 | case NodeTypeUnreachable: | |
| 5469 | return ir_lval_wrap(irb, scope, ir_build_unreachable(irb, scope, node), lval); | |
| 5470 | 5470 | case NodeTypeDefer: |
| 5471 | 5471 | return ir_lval_wrap(irb, scope, ir_gen_defer(irb, scope, node), lval); |
| 5472 | 5472 | case NodeTypeSliceExpr: |
src/parser.cpp+8-1| ... | ... | @@ -705,7 +705,7 @@ static AstNode *ast_parse_try_expr(ParseContext *pc, size_t *token_index, bool m |
| 705 | 705 | |
| 706 | 706 | /* |
| 707 | 707 | PrimaryExpression = Number | String | CharLiteral | KeywordLiteral | GroupedExpression | GotoExpression | BlockExpression | Symbol | ("@" Symbol FnCallExpression) | ArrayType | (option("extern") FnProto) | AsmExpression | ("error" "." Symbol) | ContainerDecl |
| 708 | KeywordLiteral = "true" | "false" | "null" | "break" | "continue" | "undefined" | "error" | "type" | "this" | |
| 708 | KeywordLiteral = "true" | "false" | "null" | "break" | "continue" | "undefined" | "error" | "type" | "this" | "unreachable" | |
| 709 | 709 | */ |
| 710 | 710 | static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bool mandatory) { |
| 711 | 711 | Token *token = &pc->tokens->at(*token_index); |
| ... | ... | @@ -757,6 +757,10 @@ static AstNode *ast_parse_primary_expr(ParseContext *pc, size_t *token_index, bo |
| 757 | 757 | AstNode *node = ast_create_node(pc, NodeTypeThisLiteral, token); |
| 758 | 758 | *token_index += 1; |
| 759 | 759 | return node; |
| 760 | } else if (token->id == TokenIdKeywordUnreachable) { | |
| 761 | AstNode *node = ast_create_node(pc, NodeTypeUnreachable, token); | |
| 762 | *token_index += 1; | |
| 763 | return node; | |
| 760 | 764 | } else if (token->id == TokenIdKeywordType) { |
| 761 | 765 | AstNode *node = ast_create_node(pc, NodeTypeTypeLiteral, token); |
| 762 | 766 | *token_index += 1; |
| ... | ... | @@ -2728,6 +2732,9 @@ void ast_visit_node_children(AstNode *node, void (*visit)(AstNode **, void *cont |
| 2728 | 2732 | case NodeTypeContinue: |
| 2729 | 2733 | // none |
| 2730 | 2734 | break; |
| 2735 | case NodeTypeUnreachable: | |
| 2736 | // none | |
| 2737 | break; | |
| 2731 | 2738 | case NodeTypeAsmExpr: |
| 2732 | 2739 | for (size_t i = 0; i < node->data.asm_expr.input_list.length; i += 1) { |
| 2733 | 2740 | AsmInput *asm_input = node->data.asm_expr.input_list.at(i); |
src/tokenizer.cpp+2| ... | ... | @@ -140,6 +140,7 @@ static const struct ZigKeyword zig_keywords[] = { |
| 140 | 140 | {"type", TokenIdKeywordType}, |
| 141 | 141 | {"undefined", TokenIdKeywordUndefined}, |
| 142 | 142 | {"union", TokenIdKeywordUnion}, |
| 143 | {"unreachable", TokenIdKeywordUnreachable}, | |
| 143 | 144 | {"use", TokenIdKeywordUse}, |
| 144 | 145 | {"var", TokenIdKeywordVar}, |
| 145 | 146 | {"volatile", TokenIdKeywordVolatile}, |
| ... | ... | @@ -1516,6 +1517,7 @@ const char * token_name(TokenId id) { |
| 1516 | 1517 | case TokenIdKeywordType: return "type"; |
| 1517 | 1518 | case TokenIdKeywordUndefined: return "undefined"; |
| 1518 | 1519 | case TokenIdKeywordUnion: return "union"; |
| 1520 | case TokenIdKeywordUnreachable: return "unreachable"; | |
| 1519 | 1521 | case TokenIdKeywordUse: return "use"; |
| 1520 | 1522 | case TokenIdKeywordVar: return "var"; |
| 1521 | 1523 | case TokenIdKeywordVolatile: return "volatile"; |
src/tokenizer.hpp+1| ... | ... | @@ -81,6 +81,7 @@ enum TokenId { |
| 81 | 81 | TokenIdKeywordType, |
| 82 | 82 | TokenIdKeywordUndefined, |
| 83 | 83 | TokenIdKeywordUnion, |
| 84 | TokenIdKeywordUnreachable, | |
| 84 | 85 | TokenIdKeywordUse, |
| 85 | 86 | TokenIdKeywordVar, |
| 86 | 87 | TokenIdKeywordVolatile, |
std/bootstrap.zig+4-4| ... | ... | @@ -16,10 +16,10 @@ const exit = switch(@compileVar("os")) { |
| 16 | 16 | var argc: usize = undefined; |
| 17 | 17 | var argv: &&u8 = undefined; |
| 18 | 18 | |
| 19 | export nakedcc fn _start() -> unreachable { | |
| 19 | export nakedcc fn _start() -> noreturn { | |
| 20 | 20 | @setFnVisible(this, want_start_symbol); |
| 21 | 21 | if (!want_start_symbol) { |
| 22 | @unreachable(); | |
| 22 | unreachable; | |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | switch (@compileVar("arch")) { |
| ... | ... | @@ -45,7 +45,7 @@ fn callMain() -> %void { |
| 45 | 45 | return root.main(args); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | fn callMainAndExit() -> unreachable { | |
| 48 | fn callMainAndExit() -> noreturn { | |
| 49 | 49 | callMain() %% exit(1); |
| 50 | 50 | exit(0); |
| 51 | 51 | } |
| ... | ... | @@ -53,7 +53,7 @@ fn callMainAndExit() -> unreachable { |
| 53 | 53 | export fn main(c_argc: i32, c_argv: &&u8) -> i32 { |
| 54 | 54 | @setFnVisible(this, want_main_symbol); |
| 55 | 55 | if (!want_main_symbol) { |
| 56 | @unreachable(); | |
| 56 | unreachable; | |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | argc = usize(c_argc); |
std/builtin.zig+2-2| ... | ... | @@ -31,6 +31,6 @@ export fn memcpy(noalias dest: ?&u8, noalias src: ?&const u8, n: usize) { |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | // Avoid dragging in the debug safety mechanisms into this .o file. |
| 34 | pub fn panic(message: []const u8) -> unreachable { | |
| 35 | @unreachable(); | |
| 34 | pub fn panic(message: []const u8) -> noreturn { | |
| 35 | unreachable; | |
| 36 | 36 | } |
std/c/index.zig+1-1| ... | ... | @@ -7,7 +7,7 @@ pub use switch(@compileVar("os")) { |
| 7 | 7 | else => empty_import, |
| 8 | 8 | }; |
| 9 | 9 | |
| 10 | pub extern fn abort() -> unreachable; | |
| 10 | pub extern fn abort() -> noreturn; | |
| 11 | 11 | |
| 12 | 12 | |
| 13 | 13 | const empty_import = @import("empty.zig"); |
std/compiler_rt.zig+4-4| ... | ... | @@ -1,10 +1,10 @@ |
| 1 | 1 | // Avoid dragging in the debug safety mechanisms into this .o file, |
| 2 | 2 | // unless we're trying to test this file. |
| 3 | pub fn panic(message: []const u8) -> unreachable { | |
| 3 | pub fn panic(message: []const u8) -> noreturn { | |
| 4 | 4 | if (@compileVar("is_test")) { |
| 5 | 5 | @import("std").debug.panic(message); |
| 6 | 6 | } else { |
| 7 | @unreachable(); | |
| 7 | unreachable; | |
| 8 | 8 | } |
| 9 | 9 | } |
| 10 | 10 | |
| ... | ... | @@ -259,7 +259,7 @@ export nakedcc fn __aeabi_uidivmod() { |
| 259 | 259 | \\ add sp, sp, #4 |
| 260 | 260 | \\ pop { pc } |
| 261 | 261 | ::: "r2", "r1"); |
| 262 | @unreachable(); | |
| 262 | unreachable; | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | @setFnVisible(this, false); |
| ... | ... | @@ -511,5 +511,5 @@ fn test_one_udivsi3(a: su_int, b: su_int, expected_q: su_int) { |
| 511 | 511 | |
| 512 | 512 | |
| 513 | 513 | fn assert(ok: bool) { |
| 514 | if (!ok) @unreachable(); | |
| 514 | if (!ok) unreachable; | |
| 515 | 515 | } |
std/darwin.zig+2-2| ... | ... | @@ -48,9 +48,9 @@ pub const SIGPWR = 30; |
| 48 | 48 | pub const SIGSYS = 31; |
| 49 | 49 | pub const SIGUNUSED = SIGSYS; |
| 50 | 50 | |
| 51 | pub fn exit(status: usize) -> unreachable { | |
| 51 | pub fn exit(status: usize) -> noreturn { | |
| 52 | 52 | _ = arch.syscall1(arch.SYS_exit, status); |
| 53 | @unreachable() | |
| 53 | unreachable | |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /// Get the errno from a syscall return value, or 0 for no error. |
std/debug.zig+3-3| ... | ... | @@ -10,12 +10,12 @@ error InvalidDebugInfo; |
| 10 | 10 | error UnsupportedDebugInfo; |
| 11 | 11 | |
| 12 | 12 | pub fn assert(ok: bool) { |
| 13 | if (!ok) @unreachable() | |
| 13 | if (!ok) unreachable | |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | var panicking = false; |
| 17 | 17 | /// This is the default panic implementation. |
| 18 | pub coldcc fn panic(message: []const u8) -> unreachable { | |
| 18 | pub coldcc fn panic(message: []const u8) -> noreturn { | |
| 19 | 19 | // TODO |
| 20 | 20 | // if (@atomicRmw(AtomicOp.XChg, &panicking, true, AtomicOrder.SeqCst)) { } |
| 21 | 21 | if (panicking) { |
| ... | ... | @@ -252,7 +252,7 @@ fn parseFormValueTargetAddrSize(in_stream: &io.InStream) -> %u64 { |
| 252 | 252 | } else if (@sizeOf(usize) == 8) { |
| 253 | 253 | %return in_stream.readIntLe(u64) |
| 254 | 254 | } else { |
| 255 | @unreachable(); | |
| 255 | unreachable; | |
| 256 | 256 | }; |
| 257 | 257 | } |
| 258 | 258 |
std/fmt.zig+3-3| ... | ... | @@ -287,7 +287,7 @@ fn digitToChar(digit: u8, uppercase: bool) -> u8 { |
| 287 | 287 | return switch (digit) { |
| 288 | 288 | 0 ... 9 => digit + '0', |
| 289 | 289 | 10 ... 35 => digit + ((if (uppercase) u8('A') else u8('a')) - 10), |
| 290 | else => @unreachable(), | |
| 290 | else => unreachable, | |
| 291 | 291 | }; |
| 292 | 292 | } |
| 293 | 293 | |
| ... | ... | @@ -316,9 +316,9 @@ fn bufPrintIntToSlice(buf: []u8, value: var, base: u8, uppercase: bool, width: u |
| 316 | 316 | test "testParseU64DigitTooBig" { |
| 317 | 317 | parseUnsigned(u64, "123a", 10) %% |err| { |
| 318 | 318 | if (err == error.InvalidChar) return; |
| 319 | @unreachable(); | |
| 319 | unreachable; | |
| 320 | 320 | }; |
| 321 | @unreachable(); | |
| 321 | unreachable; | |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | test "testParseUnsignedComptime" { |
std/hash_map.zig+4-4| ... | ... | @@ -50,7 +50,7 @@ pub fn HashMap(comptime K: type, comptime V: type, |
| 50 | 50 | return entry; |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | @unreachable() // no next item | |
| 53 | unreachable // no next item | |
| 54 | 54 | } |
| 55 | 55 | }; |
| 56 | 56 | |
| ... | ... | @@ -125,9 +125,9 @@ pub fn HashMap(comptime K: type, comptime V: type, |
| 125 | 125 | entry.distance_from_start_index -= 1; |
| 126 | 126 | entry = next_entry; |
| 127 | 127 | } |
| 128 | @unreachable() // shifting everything in the table | |
| 128 | unreachable // shifting everything in the table | |
| 129 | 129 | }} |
| 130 | @unreachable() // key not found | |
| 130 | unreachable // key not found | |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | pub fn entryIterator(hm: &Self) -> Iterator { |
| ... | ... | @@ -198,7 +198,7 @@ pub fn HashMap(comptime K: type, comptime V: type, |
| 198 | 198 | }; |
| 199 | 199 | return; |
| 200 | 200 | } |
| 201 | @unreachable() // put into a full map | |
| 201 | unreachable // put into a full map | |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | fn internalGet(hm: &Self, key: K) -> ?&Entry { |
std/io.zig+5-5| ... | ... | @@ -129,7 +129,7 @@ pub const OutStream = struct { |
| 129 | 129 | if (write_err > 0) { |
| 130 | 130 | return switch (write_err) { |
| 131 | 131 | errno.EINTR => continue, |
| 132 | errno.EINVAL => @unreachable(), | |
| 132 | errno.EINVAL => unreachable, | |
| 133 | 133 | errno.EDQUOT => error.DiskQuota, |
| 134 | 134 | errno.EFBIG => error.FileTooBig, |
| 135 | 135 | errno.EIO => error.Io, |
| ... | ... | @@ -171,8 +171,8 @@ pub const InStream = struct { |
| 171 | 171 | return switch (err) { |
| 172 | 172 | errno.EINTR => continue, |
| 173 | 173 | |
| 174 | errno.EFAULT => @unreachable(), | |
| 175 | errno.EINVAL => @unreachable(), | |
| 174 | errno.EFAULT => unreachable, | |
| 175 | errno.EINVAL => unreachable, | |
| 176 | 176 | errno.EACCES => error.BadPerm, |
| 177 | 177 | errno.EFBIG, errno.EOVERFLOW => error.FileTooBig, |
| 178 | 178 | errno.EISDIR => error.IsDir, |
| ... | ... | @@ -235,8 +235,8 @@ pub const InStream = struct { |
| 235 | 235 | switch (read_err) { |
| 236 | 236 | errno.EINTR => continue, |
| 237 | 237 | |
| 238 | errno.EINVAL => @unreachable(), | |
| 239 | errno.EFAULT => @unreachable(), | |
| 238 | errno.EINVAL => unreachable, | |
| 239 | errno.EFAULT => unreachable, | |
| 240 | 240 | errno.EBADF => return error.BadFd, |
| 241 | 241 | errno.EIO => return error.Io, |
| 242 | 242 | else => return error.Unexpected, |
std/linux.zig+2-2| ... | ... | @@ -297,9 +297,9 @@ pub fn lseek(fd: i32, offset: usize, ref_pos: usize) -> usize { |
| 297 | 297 | arch.syscall3(arch.SYS_lseek, usize(fd), offset, ref_pos) |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | pub fn exit(status: i32) -> unreachable { | |
| 300 | pub fn exit(status: i32) -> noreturn { | |
| 301 | 301 | _ = arch.syscall1(arch.SYS_exit, usize(status)); |
| 302 | @unreachable() | |
| 302 | unreachable | |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | pub fn getrandom(buf: &u8, count: usize, flags: u32) -> usize { |
std/math.zig+1-1| ... | ... | @@ -57,7 +57,7 @@ pub fn abs(x: var) -> @typeOf(x) { |
| 57 | 57 | } else if (@isFloat(T)) { |
| 58 | 58 | @compileError("TODO implement abs for floats"); |
| 59 | 59 | } else { |
| 60 | @unreachable(); | |
| 60 | unreachable; | |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | fn getReturnTypeForAbs(comptime T: type) -> type { |
std/net.zig+13-13| ... | ... | @@ -21,8 +21,8 @@ const Connection = struct { |
| 21 | 21 | const send_err = linux.getErrno(send_ret); |
| 22 | 22 | switch (send_err) { |
| 23 | 23 | 0 => return send_ret, |
| 24 | errno.EINVAL => @unreachable(), | |
| 25 | errno.EFAULT => @unreachable(), | |
| 24 | errno.EINVAL => unreachable, | |
| 25 | errno.EFAULT => unreachable, | |
| 26 | 26 | errno.ECONNRESET => return error.ConnectionReset, |
| 27 | 27 | errno.EINTR => return error.SigInterrupt, |
| 28 | 28 | // TODO there are more possible errors |
| ... | ... | @@ -35,8 +35,8 @@ const Connection = struct { |
| 35 | 35 | const recv_err = linux.getErrno(recv_ret); |
| 36 | 36 | switch (recv_err) { |
| 37 | 37 | 0 => return buf[0...recv_ret], |
| 38 | errno.EINVAL => @unreachable(), | |
| 39 | errno.EFAULT => @unreachable(), | |
| 38 | errno.EINVAL => unreachable, | |
| 39 | errno.EFAULT => unreachable, | |
| 40 | 40 | errno.ENOTSOCK => return error.NotSocket, |
| 41 | 41 | errno.EINTR => return error.SigInterrupt, |
| 42 | 42 | errno.ENOMEM => return error.NoMem, |
| ... | ... | @@ -50,7 +50,7 @@ const Connection = struct { |
| 50 | 50 | pub fn close(c: Connection) -> %void { |
| 51 | 51 | switch (linux.getErrno(linux.close(c.socket_fd))) { |
| 52 | 52 | 0 => return, |
| 53 | errno.EBADF => @unreachable(), | |
| 53 | errno.EBADF => unreachable, | |
| 54 | 54 | errno.EINTR => return error.SigInterrupt, |
| 55 | 55 | errno.EIO => return error.Io, |
| 56 | 56 | else => return error.Unexpected, |
| ... | ... | @@ -74,7 +74,7 @@ pub fn lookup(hostname: []const u8, out_addrs: []Address) -> %[]Address { |
| 74 | 74 | //		if (family != AF_INET) |
| 75 | 75 | //			buf[cnt++] = (struct address){ .family = AF_INET6, .addr = { [15] = 1 } }; |
| 76 | 76 | // |
| 77 | @unreachable() // TODO | |
| 77 | unreachable // TODO | |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // TODO |
| ... | ... | @@ -86,7 +86,7 @@ pub fn lookup(hostname: []const u8, out_addrs: []Address) -> %[]Address { |
| 86 | 86 | // else => {}, |
| 87 | 87 | //}; |
| 88 | 88 | |
| 89 | @unreachable() // TODO | |
| 89 | unreachable // TODO | |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | pub fn connectAddr(addr: &Address, port: u16) -> %Connection { |
| ... | ... | @@ -114,7 +114,7 @@ pub fn connectAddr(addr: &Address, port: u16) -> %Connection { |
| 114 | 114 | @memcpy(&os_addr.addr[0], &addr.addr[0], 16); |
| 115 | 115 | linux.connect(socket_fd, (&linux.sockaddr)(&os_addr), @sizeOf(linux.sockaddr_in6)) |
| 116 | 116 | } else { |
| 117 | @unreachable() | |
| 117 | unreachable | |
| 118 | 118 | }; |
| 119 | 119 | const connect_err = linux.getErrno(connect_ret); |
| 120 | 120 | if (connect_err > 0) { |
| ... | ... | @@ -324,11 +324,11 @@ fn parseIp4(buf: []const u8) -> %u32 { |
| 324 | 324 | // @setFnTest(this); |
| 325 | 325 | // |
| 326 | 326 | // assert(%%parseIp4("127.0.0.1") == endian.swapIfLe(u32, 0x7f000001)); |
| 327 | // switch (parseIp4("256.0.0.1")) { Overflow => {}, else => @unreachable(), } | |
| 328 | // switch (parseIp4("x.0.0.1")) { InvalidChar => {}, else => @unreachable(), } | |
| 329 | // switch (parseIp4("127.0.0.1.1")) { JunkAtEnd => {}, else => @unreachable(), } | |
| 330 | // switch (parseIp4("127.0.0.")) { Incomplete => {}, else => @unreachable(), } | |
| 331 | // switch (parseIp4("100..0.1")) { InvalidChar => {}, else => @unreachable(), } | |
| 327 | // switch (parseIp4("256.0.0.1")) { Overflow => {}, else => unreachable, } | |
| 328 | // switch (parseIp4("x.0.0.1")) { InvalidChar => {}, else => unreachable, } | |
| 329 | // switch (parseIp4("127.0.0.1.1")) { JunkAtEnd => {}, else => unreachable, } | |
| 330 | // switch (parseIp4("127.0.0.")) { Incomplete => {}, else => unreachable, } | |
| 331 | // switch (parseIp4("100..0.1")) { InvalidChar => {}, else => unreachable, } | |
| 332 | 332 | //} |
| 333 | 333 | // |
| 334 | 334 | //fn testParseIp6() { |
std/os.zig+3-3| ... | ... | @@ -46,8 +46,8 @@ pub fn getRandomBytes(buf: []u8) -> %void { |
| 46 | 46 | }; |
| 47 | 47 | if (err > 0) { |
| 48 | 48 | return switch (err) { |
| 49 | errno.EINVAL => @unreachable(), | |
| 50 | errno.EFAULT => @unreachable(), | |
| 49 | errno.EINVAL => unreachable, | |
| 50 | errno.EFAULT => unreachable, | |
| 51 | 51 | errno.EINTR => continue, |
| 52 | 52 | else => error.Unexpected, |
| 53 | 53 | } |
| ... | ... | @@ -59,7 +59,7 @@ pub fn getRandomBytes(buf: []u8) -> %void { |
| 59 | 59 | /// Raises a signal in the current kernel thread, ending its execution. |
| 60 | 60 | /// If linking against libc, this calls the abort() libc function. Otherwise |
| 61 | 61 | /// it uses the zig standard library implementation. |
| 62 | pub coldcc fn abort() -> unreachable { | |
| 62 | pub coldcc fn abort() -> noreturn { | |
| 63 | 63 | if (linking_libc) { |
| 64 | 64 | c.abort(); |
| 65 | 65 | } |
std/panic.zig+1-1| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | // If this file wants to import other files *by name*, support for that would |
| 4 | 4 | // have to be added in the compiler. |
| 5 | 5 | |
| 6 | pub coldcc fn panic(message: []const u8) -> unreachable { | |
| 6 | pub coldcc fn panic(message: []const u8) -> noreturn { | |
| 7 | 7 | if (@compileVar("os") == Os.freestanding) { |
| 8 | 8 | while (true) {} |
| 9 | 9 | } else { |
test/cases/enum.zig+3-3| ... | ... | @@ -16,7 +16,7 @@ test "enumType" { |
| 16 | 16 | test "enumAsReturnValue" { |
| 17 | 17 | switch (returnAnInt(13)) { |
| 18 | 18 | Foo.One => |value| assert(value == 13), |
| 19 | else => @unreachable(), | |
| 19 | else => unreachable, | |
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | |
| ... | ... | @@ -51,13 +51,13 @@ test "constantEnumWithPayload" { |
| 51 | 51 | fn shouldBeEmpty(x: &const AnEnumWithPayload) { |
| 52 | 52 | switch (*x) { |
| 53 | 53 | AnEnumWithPayload.Empty => {}, |
| 54 | else => @unreachable(), | |
| 54 | else => unreachable, | |
| 55 | 55 | } |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | fn shouldBeNotEmpty(x: &const AnEnumWithPayload) { |
| 59 | 59 | switch (*x) { |
| 60 | AnEnumWithPayload.Empty => @unreachable(), | |
| 60 | AnEnumWithPayload.Empty => unreachable, | |
| 61 | 61 | else => {}, |
| 62 | 62 | } |
| 63 | 63 | } |
test/cases/error.zig+1-1| ... | ... | @@ -48,7 +48,7 @@ error AnError; |
| 48 | 48 | error AnError; |
| 49 | 49 | error SecondError; |
| 50 | 50 | fn shouldBeNotEqual(a: error, b: error) { |
| 51 | if (a == b) @unreachable() | |
| 51 | if (a == b) unreachable | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 |
test/cases/fn.zig+3-3| ... | ... | @@ -13,7 +13,7 @@ test "localVariables" { |
| 13 | 13 | } |
| 14 | 14 | fn testLocVars(b: i32) { |
| 15 | 15 | const a: i32 = 1; |
| 16 | if (a + b != 3) @unreachable(); | |
| 16 | if (a + b != 3) unreachable; | |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | |
| ... | ... | @@ -72,8 +72,8 @@ test "implicitCastFnUnreachableReturn" { |
| 72 | 72 | |
| 73 | 73 | fn wantsFnWithVoid(f: fn()) { } |
| 74 | 74 | |
| 75 | fn fnWithUnreachable() -> unreachable { | |
| 76 | @unreachable() | |
| 75 | fn fnWithUnreachable() -> noreturn { | |
| 76 | unreachable | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 |
test/cases/for.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ test "continueInForLoop" { |
| 12 | 12 | } |
| 13 | 13 | break; |
| 14 | 14 | } |
| 15 | if (sum != 6) @unreachable() | |
| 15 | if (sum != 6) unreachable | |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | test "forLoopWithPointerElemVar" { |
test/cases/goto.zig+1-1| ... | ... | @@ -30,7 +30,7 @@ exit: |
| 30 | 30 | if (it_worked) { |
| 31 | 31 | return; |
| 32 | 32 | } |
| 33 | @unreachable(); | |
| 33 | unreachable; | |
| 34 | 34 | entry: |
| 35 | 35 | defer it_worked = true; |
| 36 | 36 | if (b) goto exit; |
test/cases/if.zig+4-4| ... | ... | @@ -6,20 +6,20 @@ test "ifStatements" { |
| 6 | 6 | } |
| 7 | 7 | fn shouldBeEqual(a: i32, b: i32) { |
| 8 | 8 | if (a != b) { |
| 9 | @unreachable(); | |
| 9 | unreachable; | |
| 10 | 10 | } else { |
| 11 | 11 | return; |
| 12 | 12 | } |
| 13 | 13 | } |
| 14 | 14 | fn firstEqlThird(a: i32, b: i32, c: i32) { |
| 15 | 15 | if (a == b) { |
| 16 | @unreachable(); | |
| 16 | unreachable; | |
| 17 | 17 | } else if (b == c) { |
| 18 | @unreachable(); | |
| 18 | unreachable; | |
| 19 | 19 | } else if (a == c) { |
| 20 | 20 | return; |
| 21 | 21 | } else { |
| 22 | @unreachable(); | |
| 22 | unreachable; | |
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 |
test/cases/misc.zig+6-6| ... | ... | @@ -163,7 +163,7 @@ test "memcpyAndMemsetIntrinsics" { |
| 163 | 163 | @memset(&foo[0], 'A', foo.len); |
| 164 | 164 | @memcpy(&bar[0], &foo[0], bar.len); |
| 165 | 165 | |
| 166 | if (bar[11] != 'A') @unreachable(); | |
| 166 | if (bar[11] != 'A') unreachable; | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | test "builtinStaticEval" { |
| ... | ... | @@ -178,13 +178,13 @@ test "slicing" { |
| 178 | 178 | |
| 179 | 179 | var slice = array[5...10]; |
| 180 | 180 | |
| 181 | if (slice.len != 5) @unreachable(); | |
| 181 | if (slice.len != 5) unreachable; | |
| 182 | 182 | |
| 183 | 183 | const ptr = &slice[0]; |
| 184 | if (ptr[0] != 1234) @unreachable(); | |
| 184 | if (ptr[0] != 1234) unreachable; | |
| 185 | 185 | |
| 186 | 186 | var slice_rest = array[10...]; |
| 187 | if (slice_rest.len != 10) @unreachable(); | |
| 187 | if (slice_rest.len != 10) unreachable; | |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | |
| ... | ... | @@ -344,7 +344,7 @@ fn test3_1(f: &const Test3Foo) { |
| 344 | 344 | assert(pt.x == 3); |
| 345 | 345 | assert(pt.y == 4); |
| 346 | 346 | }, |
| 347 | else => @unreachable(), | |
| 347 | else => unreachable, | |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | fn test3_2(f: &const Test3Foo) { |
| ... | ... | @@ -352,7 +352,7 @@ fn test3_2(f: &const Test3Foo) { |
| 352 | 352 | Test3Foo.Two => |x| { |
| 353 | 353 | assert(x == 13); |
| 354 | 354 | }, |
| 355 | else => @unreachable(), | |
| 355 | else => unreachable, | |
| 356 | 356 | } |
| 357 | 357 | } |
| 358 | 358 |
test/cases/null.zig+3-3| ... | ... | @@ -7,10 +7,10 @@ test "nullableType" { |
| 7 | 7 | if (y) { |
| 8 | 8 | // OK |
| 9 | 9 | } else { |
| 10 | @unreachable(); | |
| 10 | unreachable; | |
| 11 | 11 | } |
| 12 | 12 | } else { |
| 13 | @unreachable(); | |
| 13 | unreachable; | |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | const next_x : ?i32 = @generatedCode(null); |
| ... | ... | @@ -21,7 +21,7 @@ test "nullableType" { |
| 21 | 21 | |
| 22 | 22 | const final_x : ?i32 = @generatedCode(13); |
| 23 | 23 | |
| 24 | const num = final_x ?? @unreachable(); | |
| 24 | const num = final_x ?? unreachable; | |
| 25 | 25 | |
| 26 | 26 | assert(num == 13); |
| 27 | 27 | } |
test/cases/switch.zig+5-5| ... | ... | @@ -55,9 +55,9 @@ const Fruit = enum { |
| 55 | 55 | }; |
| 56 | 56 | fn nonConstSwitchOnEnum(fruit: Fruit) { |
| 57 | 57 | switch (fruit) { |
| 58 | Fruit.Apple => @unreachable(), | |
| 58 | Fruit.Apple => unreachable, | |
| 59 | 59 | Fruit.Orange => {}, |
| 60 | Fruit.Banana => @unreachable(), | |
| 60 | Fruit.Banana => unreachable, | |
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| ... | ... | @@ -72,7 +72,7 @@ fn nonConstSwitch(foo: SwitchStatmentFoo) { |
| 72 | 72 | SwitchStatmentFoo.C => 3, |
| 73 | 73 | SwitchStatmentFoo.D => 4, |
| 74 | 74 | }; |
| 75 | if (val != 3) @unreachable(); | |
| 75 | if (val != 3) unreachable; | |
| 76 | 76 | } |
| 77 | 77 | const SwitchStatmentFoo = enum { |
| 78 | 78 | A, |
| ... | ... | @@ -95,10 +95,10 @@ const SwitchProngWithVarEnum = enum { |
| 95 | 95 | fn switchProngWithVarFn(a: &const SwitchProngWithVarEnum) { |
| 96 | 96 | switch(*a) { |
| 97 | 97 | SwitchProngWithVarEnum.One => |x| { |
| 98 | if (x != 13) @unreachable(); | |
| 98 | if (x != 13) unreachable; | |
| 99 | 99 | }, |
| 100 | 100 | SwitchProngWithVarEnum.Two => |x| { |
| 101 | if (x != 13.0) @unreachable(); | |
| 101 | if (x != 13.0) unreachable; | |
| 102 | 102 | }, |
| 103 | 103 | SwitchProngWithVarEnum.Meh => |x| { |
| 104 | 104 | const v: void = x; |
test/cases/try.zig+1-1| ... | ... | @@ -52,7 +52,7 @@ fn failIfTrue(ok: bool) -> %void { |
| 52 | 52 | // @setFnTest(this); |
| 53 | 53 | // |
| 54 | 54 | // try (_ = failIfTrue(true)) { |
| 55 | // @unreachable(); | |
| 55 | // unreachable; | |
| 56 | 56 | // } else |err| { |
| 57 | 57 | // assert(err == error.ItBroke); |
| 58 | 58 | // } |
test/run_tests.cpp+25-25| ... | ... | @@ -471,8 +471,8 @@ const foo : i32 = 0; |
| 471 | 471 | const c = @cImport(@cInclude("stdlib.h")); |
| 472 | 472 | |
| 473 | 473 | export fn compare_fn(a: ?&const c_void, b: ?&const c_void) -> c_int { |
| 474 | const a_int = (&i32)(a ?? @unreachable()); | |
| 475 | const b_int = (&i32)(b ?? @unreachable()); | |
| 474 | const a_int = (&i32)(a ?? unreachable); | |
| 475 | const b_int = (&i32)(b ?? unreachable); | |
| 476 | 476 | if (*a_int < *b_int) { |
| 477 | 477 | -1 |
| 478 | 478 | } else if (*a_int > *b_int) { |
| ... | ... | @@ -628,9 +628,9 @@ export fn entry() { a(); } |
| 628 | 628 | )SOURCE", 1, ".tmp_source.zig:3:1: error: redefinition of 'a'"); |
| 629 | 629 | |
| 630 | 630 | add_compile_fail_case("unreachable with return", R"SOURCE( |
| 631 | fn a() -> unreachable {return;} | |
| 631 | fn a() -> noreturn {return;} | |
| 632 | 632 | export fn entry() { a(); } |
| 633 | )SOURCE", 1, ".tmp_source.zig:2:24: error: expected type 'unreachable', found 'void'"); | |
| 633 | )SOURCE", 1, ".tmp_source.zig:2:21: error: expected type 'noreturn', found 'void'"); | |
| 634 | 634 | |
| 635 | 635 | add_compile_fail_case("control reaches end of non-void function", R"SOURCE( |
| 636 | 636 | fn a() -> i32 {} |
| ... | ... | @@ -656,7 +656,7 @@ export fn entry() { _ = a(); } |
| 656 | 656 | )SOURCE", 1, ".tmp_source.zig:2:11: error: use of undeclared identifier 'bogus'"); |
| 657 | 657 | |
| 658 | 658 | add_compile_fail_case("pointer to unreachable", R"SOURCE( |
| 659 | fn a() -> &unreachable {} | |
| 659 | fn a() -> &noreturn {} | |
| 660 | 660 | export fn entry() { _ = a(); } |
| 661 | 661 | )SOURCE", 1, ".tmp_source.zig:2:12: error: pointer to unreachable not allowed"); |
| 662 | 662 | |
| ... | ... | @@ -724,14 +724,14 @@ export fn f() { |
| 724 | 724 | |
| 725 | 725 | add_compile_fail_case("unreachable variable", R"SOURCE( |
| 726 | 726 | export fn f() { |
| 727 | const a : unreachable = {}; | |
| 727 | const a: noreturn = {}; | |
| 728 | 728 | } |
| 729 | )SOURCE", 1, ".tmp_source.zig:3:15: error: variable of type 'unreachable' not allowed"); | |
| 729 | )SOURCE", 1, ".tmp_source.zig:3:14: error: variable of type 'noreturn' not allowed"); | |
| 730 | 730 | |
| 731 | 731 | add_compile_fail_case("unreachable parameter", R"SOURCE( |
| 732 | fn f(a : unreachable) {} | |
| 732 | fn f(a: noreturn) {} | |
| 733 | 733 | export fn entry() { f(); } |
| 734 | )SOURCE", 1, ".tmp_source.zig:2:10: error: parameter of type 'unreachable' not allowed"); | |
| 734 | )SOURCE", 1, ".tmp_source.zig:2:9: error: parameter of type 'noreturn' not allowed"); | |
| 735 | 735 | |
| 736 | 736 | add_compile_fail_case("bad assignment target", R"SOURCE( |
| 737 | 737 | export fn f() { |
| ... | ... | @@ -1737,7 +1737,7 @@ export fn foo() { |
| 1737 | 1737 | } |
| 1738 | 1738 | |
| 1739 | 1739 | fn assert(ok: bool) { |
| 1740 | if (!ok) @unreachable(); | |
| 1740 | if (!ok) unreachable; | |
| 1741 | 1741 | } |
| 1742 | 1742 | )SOURCE", 2, |
| 1743 | 1743 | ".tmp_source.zig:11:14: error: unable to evaluate constant expression", |
| ... | ... | @@ -1830,7 +1830,7 @@ export fn entry() { |
| 1830 | 1830 | |
| 1831 | 1831 | static void add_debug_safety_test_cases(void) { |
| 1832 | 1832 | add_debug_safety_case("out of bounds slice access", R"SOURCE( |
| 1833 | pub fn panic(message: []const u8) -> unreachable { | |
| 1833 | pub fn panic(message: []const u8) -> noreturn { | |
| 1834 | 1834 | @breakpoint(); |
| 1835 | 1835 | while (true) {} |
| 1836 | 1836 | } |
| ... | ... | @@ -1845,7 +1845,7 @@ fn baz(a: i32) { } |
| 1845 | 1845 | )SOURCE"); |
| 1846 | 1846 | |
| 1847 | 1847 | add_debug_safety_case("integer addition overflow", R"SOURCE( |
| 1848 | pub fn panic(message: []const u8) -> unreachable { | |
| 1848 | pub fn panic(message: []const u8) -> noreturn { | |
| 1849 | 1849 | @breakpoint(); |
| 1850 | 1850 | while (true) {} |
| 1851 | 1851 | } |
| ... | ... | @@ -1860,7 +1860,7 @@ fn add(a: u16, b: u16) -> u16 { |
| 1860 | 1860 | )SOURCE"); |
| 1861 | 1861 | |
| 1862 | 1862 | add_debug_safety_case("integer subtraction overflow", R"SOURCE( |
| 1863 | pub fn panic(message: []const u8) -> unreachable { | |
| 1863 | pub fn panic(message: []const u8) -> noreturn { | |
| 1864 | 1864 | @breakpoint(); |
| 1865 | 1865 | while (true) {} |
| 1866 | 1866 | } |
| ... | ... | @@ -1875,7 +1875,7 @@ fn sub(a: u16, b: u16) -> u16 { |
| 1875 | 1875 | )SOURCE"); |
| 1876 | 1876 | |
| 1877 | 1877 | add_debug_safety_case("integer multiplication overflow", R"SOURCE( |
| 1878 | pub fn panic(message: []const u8) -> unreachable { | |
| 1878 | pub fn panic(message: []const u8) -> noreturn { | |
| 1879 | 1879 | @breakpoint(); |
| 1880 | 1880 | while (true) {} |
| 1881 | 1881 | } |
| ... | ... | @@ -1890,7 +1890,7 @@ fn mul(a: u16, b: u16) -> u16 { |
| 1890 | 1890 | )SOURCE"); |
| 1891 | 1891 | |
| 1892 | 1892 | add_debug_safety_case("integer negation overflow", R"SOURCE( |
| 1893 | pub fn panic(message: []const u8) -> unreachable { | |
| 1893 | pub fn panic(message: []const u8) -> noreturn { | |
| 1894 | 1894 | @breakpoint(); |
| 1895 | 1895 | while (true) {} |
| 1896 | 1896 | } |
| ... | ... | @@ -1905,7 +1905,7 @@ fn neg(a: i16) -> i16 { |
| 1905 | 1905 | )SOURCE"); |
| 1906 | 1906 | |
| 1907 | 1907 | add_debug_safety_case("signed integer division overflow", R"SOURCE( |
| 1908 | pub fn panic(message: []const u8) -> unreachable { | |
| 1908 | pub fn panic(message: []const u8) -> noreturn { | |
| 1909 | 1909 | @breakpoint(); |
| 1910 | 1910 | while (true) {} |
| 1911 | 1911 | } |
| ... | ... | @@ -1920,7 +1920,7 @@ fn div(a: i16, b: i16) -> i16 { |
| 1920 | 1920 | )SOURCE"); |
| 1921 | 1921 | |
| 1922 | 1922 | add_debug_safety_case("signed shift left overflow", R"SOURCE( |
| 1923 | pub fn panic(message: []const u8) -> unreachable { | |
| 1923 | pub fn panic(message: []const u8) -> noreturn { | |
| 1924 | 1924 | @breakpoint(); |
| 1925 | 1925 | while (true) {} |
| 1926 | 1926 | } |
| ... | ... | @@ -1935,7 +1935,7 @@ fn shl(a: i16, b: i16) -> i16 { |
| 1935 | 1935 | )SOURCE"); |
| 1936 | 1936 | |
| 1937 | 1937 | add_debug_safety_case("unsigned shift left overflow", R"SOURCE( |
| 1938 | pub fn panic(message: []const u8) -> unreachable { | |
| 1938 | pub fn panic(message: []const u8) -> noreturn { | |
| 1939 | 1939 | @breakpoint(); |
| 1940 | 1940 | while (true) {} |
| 1941 | 1941 | } |
| ... | ... | @@ -1950,7 +1950,7 @@ fn shl(a: u16, b: u16) -> u16 { |
| 1950 | 1950 | )SOURCE"); |
| 1951 | 1951 | |
| 1952 | 1952 | add_debug_safety_case("integer division by zero", R"SOURCE( |
| 1953 | pub fn panic(message: []const u8) -> unreachable { | |
| 1953 | pub fn panic(message: []const u8) -> noreturn { | |
| 1954 | 1954 | @breakpoint(); |
| 1955 | 1955 | while (true) {} |
| 1956 | 1956 | } |
| ... | ... | @@ -1964,7 +1964,7 @@ fn div0(a: i32, b: i32) -> i32 { |
| 1964 | 1964 | )SOURCE"); |
| 1965 | 1965 | |
| 1966 | 1966 | add_debug_safety_case("exact division failure", R"SOURCE( |
| 1967 | pub fn panic(message: []const u8) -> unreachable { | |
| 1967 | pub fn panic(message: []const u8) -> noreturn { | |
| 1968 | 1968 | @breakpoint(); |
| 1969 | 1969 | while (true) {} |
| 1970 | 1970 | } |
| ... | ... | @@ -1979,7 +1979,7 @@ fn divExact(a: i32, b: i32) -> i32 { |
| 1979 | 1979 | )SOURCE"); |
| 1980 | 1980 | |
| 1981 | 1981 | add_debug_safety_case("cast []u8 to bigger slice of wrong size", R"SOURCE( |
| 1982 | pub fn panic(message: []const u8) -> unreachable { | |
| 1982 | pub fn panic(message: []const u8) -> noreturn { | |
| 1983 | 1983 | @breakpoint(); |
| 1984 | 1984 | while (true) {} |
| 1985 | 1985 | } |
| ... | ... | @@ -1994,7 +1994,7 @@ fn widenSlice(slice: []const u8) -> []const i32 { |
| 1994 | 1994 | )SOURCE"); |
| 1995 | 1995 | |
| 1996 | 1996 | add_debug_safety_case("value does not fit in shortening cast", R"SOURCE( |
| 1997 | pub fn panic(message: []const u8) -> unreachable { | |
| 1997 | pub fn panic(message: []const u8) -> noreturn { | |
| 1998 | 1998 | @breakpoint(); |
| 1999 | 1999 | while (true) {} |
| 2000 | 2000 | } |
| ... | ... | @@ -2009,7 +2009,7 @@ fn shorten_cast(x: i32) -> i8 { |
| 2009 | 2009 | )SOURCE"); |
| 2010 | 2010 | |
| 2011 | 2011 | add_debug_safety_case("signed integer not fitting in cast to unsigned integer", R"SOURCE( |
| 2012 | pub fn panic(message: []const u8) -> unreachable { | |
| 2012 | pub fn panic(message: []const u8) -> noreturn { | |
| 2013 | 2013 | @breakpoint(); |
| 2014 | 2014 | while (true) {} |
| 2015 | 2015 | } |
| ... | ... | @@ -2024,7 +2024,7 @@ fn unsigned_cast(x: i32) -> u32 { |
| 2024 | 2024 | )SOURCE"); |
| 2025 | 2025 | |
| 2026 | 2026 | add_debug_safety_case("unwrap error", R"SOURCE( |
| 2027 | pub fn panic(message: []const u8) -> unreachable { | |
| 2027 | pub fn panic(message: []const u8) -> noreturn { | |
| 2028 | 2028 | @breakpoint(); |
| 2029 | 2029 | while (true) {} |
| 2030 | 2030 | } |
| ... | ... | @@ -2055,7 +2055,7 @@ void baz(int8_t a, int16_t b, int32_t c, int64_t d); |
| 2055 | 2055 | |
| 2056 | 2056 | add_parseh_case("noreturn attribute", AllowWarningsNo, R"SOURCE( |
| 2057 | 2057 | void foo(void) __attribute__((noreturn)); |
| 2058 | )SOURCE", 1, R"OUTPUT(pub extern fn foo() -> unreachable;)OUTPUT"); | |
| 2058 | )SOURCE", 1, R"OUTPUT(pub extern fn foo() -> noreturn;)OUTPUT"); | |
| 2059 | 2059 | |
| 2060 | 2060 | add_parseh_case("enums", AllowWarningsNo, R"SOURCE( |
| 2061 | 2061 | enum Foo { |