| author | |
| committer | |
| log | b3a6faf13ebccb82bb5fa82012bb62699a8ff6fb |
| tree | c0daed782354e52721845e87ecb62ef491ec70d7 |
| parent | ad2527d47af6b6f22e0e9d127417a30c50b69c35 |
See #632
now we have 1 less sigil21 files changed, 87 insertions(+), 89 deletions(-)
doc/docgen.zig+2-2| ... | @@ -318,7 +318,7 @@ const Action = enum { | ... | @@ -318,7 +318,7 @@ const Action = enum { |
| 318 | 318 | ||
| 319 | fn genToc(allocator: &mem.Allocator, tokenizer: &Tokenizer) -> %Toc { | 319 | fn genToc(allocator: &mem.Allocator, tokenizer: &Tokenizer) -> %Toc { |
| 320 | var urls = std.HashMap([]const u8, Token, mem.hash_slice_u8, mem.eql_slice_u8).init(allocator); | 320 | var urls = std.HashMap([]const u8, Token, mem.hash_slice_u8, mem.eql_slice_u8).init(allocator); |
| 321 | %defer urls.deinit(); | 321 | errdefer urls.deinit(); |
| 322 | 322 | ||
| 323 | var header_stack_size: usize = 0; | 323 | var header_stack_size: usize = 0; |
| 324 | var last_action = Action.Open; | 324 | var last_action = Action.Open; |
| ... | @@ -399,7 +399,7 @@ fn genToc(allocator: &mem.Allocator, tokenizer: &Tokenizer) -> %Toc { | ... | @@ -399,7 +399,7 @@ fn genToc(allocator: &mem.Allocator, tokenizer: &Tokenizer) -> %Toc { |
| 399 | } | 399 | } |
| 400 | } else if (mem.eql(u8, tag_name, "see_also")) { | 400 | } else if (mem.eql(u8, tag_name, "see_also")) { |
| 401 | var list = std.ArrayList(SeeAlsoItem).init(allocator); | 401 | var list = std.ArrayList(SeeAlsoItem).init(allocator); |
| 402 | %defer list.deinit(); | 402 | errdefer list.deinit(); |
| 403 | 403 | ||
| 404 | while (true) { | 404 | while (true) { |
| 405 | const see_also_tok = tokenizer.next(); | 405 | const see_also_tok = tokenizer.next(); |
doc/langref.html.in+7-7| ... | @@ -2533,7 +2533,7 @@ test "defer unwinding" { | ... | @@ -2533,7 +2533,7 @@ test "defer unwinding" { |
| 2533 | deferUnwindExample(); | 2533 | deferUnwindExample(); |
| 2534 | } | 2534 | } |
| 2535 | 2535 | ||
| 2536 | // The %defer keyword is similar to defer, but will only execute if the | 2536 | // The errdefer keyword is similar to defer, but will only execute if the |
| 2537 | // scope returns with an error. | 2537 | // scope returns with an error. |
| 2538 | // | 2538 | // |
| 2539 | // This is especially useful in allowing a function to clean up properly | 2539 | // This is especially useful in allowing a function to clean up properly |
| ... | @@ -2547,7 +2547,7 @@ fn deferErrorExample(is_error: bool) -> %void { | ... | @@ -2547,7 +2547,7 @@ fn deferErrorExample(is_error: bool) -> %void { |
| 2547 | warn("end of function\n"); | 2547 | warn("end of function\n"); |
| 2548 | } | 2548 | } |
| 2549 | 2549 | ||
| 2550 | %defer { | 2550 | errdefer { |
| 2551 | warn("encountered an error!\n"); | 2551 | warn("encountered an error!\n"); |
| 2552 | } | 2552 | } |
| 2553 | 2553 | ||
| ... | @@ -2556,7 +2556,7 @@ fn deferErrorExample(is_error: bool) -> %void { | ... | @@ -2556,7 +2556,7 @@ fn deferErrorExample(is_error: bool) -> %void { |
| 2556 | } | 2556 | } |
| 2557 | } | 2557 | } |
| 2558 | 2558 | ||
| 2559 | test "%defer unwinding" { | 2559 | test "errdefer unwinding" { |
| 2560 | _ = deferErrorExample(false); | 2560 | _ = deferErrorExample(false); |
| 2561 | _ = deferErrorExample(true); | 2561 | _ = deferErrorExample(true); |
| 2562 | } | 2562 | } |
| ... | @@ -2922,7 +2922,7 @@ fn doAThing(str: []u8) { | ... | @@ -2922,7 +2922,7 @@ fn doAThing(str: []u8) { |
| 2922 | {#code_end#} | 2922 | {#code_end#} |
| 2923 | <p> | 2923 | <p> |
| 2924 | The other component to error handling is defer statements. | 2924 | The other component to error handling is defer statements. |
| 2925 | In addition to an unconditional <code>defer</code>, Zig has <code>%defer</code>, | 2925 | In addition to an unconditional <code>defer</code>, Zig has <code>errdefer</code>, |
| 2926 | which evaluates the deferred expression on block exit path if and only if | 2926 | which evaluates the deferred expression on block exit path if and only if |
| 2927 | the function returned with an error from the block. | 2927 | the function returned with an error from the block. |
| 2928 | </p> | 2928 | </p> |
| ... | @@ -2934,7 +2934,7 @@ fn createFoo(param: i32) -> %Foo { | ... | @@ -2934,7 +2934,7 @@ fn createFoo(param: i32) -> %Foo { |
| 2934 | const foo = try tryToAllocateFoo(); | 2934 | const foo = try tryToAllocateFoo(); |
| 2935 | // now we have allocated foo. we need to free it if the function fails. | 2935 | // now we have allocated foo. we need to free it if the function fails. |
| 2936 | // but we want to return it if the function succeeds. | 2936 | // but we want to return it if the function succeeds. |
| 2937 | %defer deallocateFoo(foo); | 2937 | errdefer deallocateFoo(foo); |
| 2938 | 2938 | ||
| 2939 | const tmp_buf = allocateTmpBuffer() ?? return error.OutOfMemory; | 2939 | const tmp_buf = allocateTmpBuffer() ?? return error.OutOfMemory; |
| 2940 | // tmp_buf is truly a temporary resource, and we for sure want to clean it up | 2940 | // tmp_buf is truly a temporary resource, and we for sure want to clean it up |
| ... | @@ -2943,7 +2943,7 @@ fn createFoo(param: i32) -> %Foo { | ... | @@ -2943,7 +2943,7 @@ fn createFoo(param: i32) -> %Foo { |
| 2943 | 2943 | ||
| 2944 | if (param > 1337) return error.InvalidParam; | 2944 | if (param > 1337) return error.InvalidParam; |
| 2945 | 2945 | ||
| 2946 | // here the %defer will not run since we're returning success from the function. | 2946 | // here the errdefer will not run since we're returning success from the function. |
| 2947 | // but the defer will run! | 2947 | // but the defer will run! |
| 2948 | return foo; | 2948 | return foo; |
| 2949 | } | 2949 | } |
| ... | @@ -5619,7 +5619,7 @@ TryExpression = "try" Expression | ... | @@ -5619,7 +5619,7 @@ TryExpression = "try" Expression |
| 5619 | 5619 | ||
| 5620 | BreakExpression = "break" option(":" Symbol) option(Expression) | 5620 | BreakExpression = "break" option(":" Symbol) option(Expression) |
| 5621 | 5621 | ||
| 5622 | Defer(body) = option("%") "defer" body | 5622 | Defer(body) = ("defer" | "deferror") body |
| 5623 | 5623 | ||
| 5624 | IfExpression(body) = "if" "(" Expression ")" body option("else" BlockExpression(body)) | 5624 | IfExpression(body) = "if" "(" Expression ")" body option("else" BlockExpression(body)) |
| 5625 | 5625 |
src-self-hosted/main.zig+2-2| ... | @@ -371,7 +371,7 @@ pub fn main2() -> %void { | ... | @@ -371,7 +371,7 @@ pub fn main2() -> %void { |
| 371 | defer allocator.free(full_cache_dir); | 371 | defer allocator.free(full_cache_dir); |
| 372 | 372 | ||
| 373 | const zig_lib_dir = try resolveZigLibDir(allocator, zig_install_prefix); | 373 | const zig_lib_dir = try resolveZigLibDir(allocator, zig_install_prefix); |
| 374 | %defer allocator.free(zig_lib_dir); | 374 | errdefer allocator.free(zig_lib_dir); |
| 375 | 375 | ||
| 376 | const module = try Module.create(allocator, root_name, zig_root_source_file, | 376 | const module = try Module.create(allocator, root_name, zig_root_source_file, |
| 377 | Target.Native, build_kind, build_mode, zig_lib_dir, full_cache_dir); | 377 | Target.Native, build_kind, build_mode, zig_lib_dir, full_cache_dir); |
| ... | @@ -587,7 +587,7 @@ fn resolveZigLibDir(allocator: &mem.Allocator, zig_install_prefix_arg: ?[]const | ... | @@ -587,7 +587,7 @@ fn resolveZigLibDir(allocator: &mem.Allocator, zig_install_prefix_arg: ?[]const |
| 587 | /// Caller must free result | 587 | /// Caller must free result |
| 588 | fn testZigInstallPrefix(allocator: &mem.Allocator, test_path: []const u8) -> %[]u8 { | 588 | fn testZigInstallPrefix(allocator: &mem.Allocator, test_path: []const u8) -> %[]u8 { |
| 589 | const test_zig_dir = try os.path.join(allocator, test_path, "lib", "zig"); | 589 | const test_zig_dir = try os.path.join(allocator, test_path, "lib", "zig"); |
| 590 | %defer allocator.free(test_zig_dir); | 590 | errdefer allocator.free(test_zig_dir); |
| 591 | 591 | ||
| 592 | const test_index_file = try os.path.join(allocator, test_zig_dir, "std", "index.zig"); | 592 | const test_index_file = try os.path.join(allocator, test_zig_dir, "std", "index.zig"); |
| 593 | defer allocator.free(test_index_file); | 593 | defer allocator.free(test_index_file); |
src-self-hosted/module.zig+7-7| ... | @@ -113,19 +113,19 @@ pub const Module = struct { | ... | @@ -113,19 +113,19 @@ pub const Module = struct { |
| 113 | kind: Kind, build_mode: builtin.Mode, zig_lib_dir: []const u8, cache_dir: []const u8) -> %&Module | 113 | kind: Kind, build_mode: builtin.Mode, zig_lib_dir: []const u8, cache_dir: []const u8) -> %&Module |
| 114 | { | 114 | { |
| 115 | var name_buffer = try Buffer.init(allocator, name); | 115 | var name_buffer = try Buffer.init(allocator, name); |
| 116 | %defer name_buffer.deinit(); | 116 | errdefer name_buffer.deinit(); |
| 117 | 117 | ||
| 118 | const context = c.LLVMContextCreate() ?? return error.OutOfMemory; | 118 | const context = c.LLVMContextCreate() ?? return error.OutOfMemory; |
| 119 | %defer c.LLVMContextDispose(context); | 119 | errdefer c.LLVMContextDispose(context); |
| 120 | 120 | ||
| 121 | const module = c.LLVMModuleCreateWithNameInContext(name_buffer.ptr(), context) ?? return error.OutOfMemory; | 121 | const module = c.LLVMModuleCreateWithNameInContext(name_buffer.ptr(), context) ?? return error.OutOfMemory; |
| 122 | %defer c.LLVMDisposeModule(module); | 122 | errdefer c.LLVMDisposeModule(module); |
| 123 | 123 | ||
| 124 | const builder = c.LLVMCreateBuilderInContext(context) ?? return error.OutOfMemory; | 124 | const builder = c.LLVMCreateBuilderInContext(context) ?? return error.OutOfMemory; |
| 125 | %defer c.LLVMDisposeBuilder(builder); | 125 | errdefer c.LLVMDisposeBuilder(builder); |
| 126 | 126 | ||
| 127 | const module_ptr = try allocator.create(Module); | 127 | const module_ptr = try allocator.create(Module); |
| 128 | %defer allocator.destroy(module_ptr); | 128 | errdefer allocator.destroy(module_ptr); |
| 129 | 129 | ||
| 130 | *module_ptr = Module { | 130 | *module_ptr = Module { |
| 131 | .allocator = allocator, | 131 | .allocator = allocator, |
| ... | @@ -211,13 +211,13 @@ pub const Module = struct { | ... | @@ -211,13 +211,13 @@ pub const Module = struct { |
| 211 | try printError("unable to get real path '{}': {}", root_src_path, err); | 211 | try printError("unable to get real path '{}': {}", root_src_path, err); |
| 212 | return err; | 212 | return err; |
| 213 | }; | 213 | }; |
| 214 | %defer self.allocator.free(root_src_real_path); | 214 | errdefer self.allocator.free(root_src_real_path); |
| 215 | 215 | ||
| 216 | const source_code = io.readFileAllocExtra(root_src_real_path, self.allocator, 3) catch |err| { | 216 | const source_code = io.readFileAllocExtra(root_src_real_path, self.allocator, 3) catch |err| { |
| 217 | try printError("unable to open '{}': {}", root_src_real_path, err); | 217 | try printError("unable to open '{}': {}", root_src_real_path, err); |
| 218 | return err; | 218 | return err; |
| 219 | }; | 219 | }; |
| 220 | %defer self.allocator.free(source_code); | 220 | errdefer self.allocator.free(source_code); |
| 221 | source_code[source_code.len - 3] = '\n'; | 221 | source_code[source_code.len - 3] = '\n'; |
| 222 | source_code[source_code.len - 2] = '\n'; | 222 | source_code[source_code.len - 2] = '\n'; |
| 223 | source_code[source_code.len - 1] = '\n'; | 223 | source_code[source_code.len - 1] = '\n'; |
src-self-hosted/parser.zig+15-15| ... | @@ -127,7 +127,7 @@ pub const Parser = struct { | ... | @@ -127,7 +127,7 @@ pub const Parser = struct { |
| 127 | 127 | ||
| 128 | const root_node = x: { | 128 | const root_node = x: { |
| 129 | const root_node = try self.createRoot(); | 129 | const root_node = try self.createRoot(); |
| 130 | %defer self.allocator.destroy(root_node); | 130 | errdefer self.allocator.destroy(root_node); |
| 131 | // This stack append has to succeed for freeAst to work | 131 | // This stack append has to succeed for freeAst to work |
| 132 | try stack.append(State.TopLevel); | 132 | try stack.append(State.TopLevel); |
| 133 | break :x root_node; | 133 | break :x root_node; |
| ... | @@ -577,7 +577,7 @@ pub const Parser = struct { | ... | @@ -577,7 +577,7 @@ pub const Parser = struct { |
| 577 | 577 | ||
| 578 | fn createRoot(self: &Parser) -> %&ast.NodeRoot { | 578 | fn createRoot(self: &Parser) -> %&ast.NodeRoot { |
| 579 | const node = try self.allocator.create(ast.NodeRoot); | 579 | const node = try self.allocator.create(ast.NodeRoot); |
| 580 | %defer self.allocator.destroy(node); | 580 | errdefer self.allocator.destroy(node); |
| 581 | 581 | ||
| 582 | *node = ast.NodeRoot { | 582 | *node = ast.NodeRoot { |
| 583 | .base = ast.Node {.id = ast.Node.Id.Root}, | 583 | .base = ast.Node {.id = ast.Node.Id.Root}, |
| ... | @@ -590,7 +590,7 @@ pub const Parser = struct { | ... | @@ -590,7 +590,7 @@ pub const Parser = struct { |
| 590 | extern_token: &const ?Token) -> %&ast.NodeVarDecl | 590 | extern_token: &const ?Token) -> %&ast.NodeVarDecl |
| 591 | { | 591 | { |
| 592 | const node = try self.allocator.create(ast.NodeVarDecl); | 592 | const node = try self.allocator.create(ast.NodeVarDecl); |
| 593 | %defer self.allocator.destroy(node); | 593 | errdefer self.allocator.destroy(node); |
| 594 | 594 | ||
| 595 | *node = ast.NodeVarDecl { | 595 | *node = ast.NodeVarDecl { |
| 596 | .base = ast.Node {.id = ast.Node.Id.VarDecl}, | 596 | .base = ast.Node {.id = ast.Node.Id.VarDecl}, |
| ... | @@ -613,7 +613,7 @@ pub const Parser = struct { | ... | @@ -613,7 +613,7 @@ pub const Parser = struct { |
| 613 | cc_token: &const ?Token, visib_token: &const ?Token, inline_token: &const ?Token) -> %&ast.NodeFnProto | 613 | cc_token: &const ?Token, visib_token: &const ?Token, inline_token: &const ?Token) -> %&ast.NodeFnProto |
| 614 | { | 614 | { |
| 615 | const node = try self.allocator.create(ast.NodeFnProto); | 615 | const node = try self.allocator.create(ast.NodeFnProto); |
| 616 | %defer self.allocator.destroy(node); | 616 | errdefer self.allocator.destroy(node); |
| 617 | 617 | ||
| 618 | *node = ast.NodeFnProto { | 618 | *node = ast.NodeFnProto { |
| 619 | .base = ast.Node {.id = ast.Node.Id.FnProto}, | 619 | .base = ast.Node {.id = ast.Node.Id.FnProto}, |
| ... | @@ -635,7 +635,7 @@ pub const Parser = struct { | ... | @@ -635,7 +635,7 @@ pub const Parser = struct { |
| 635 | 635 | ||
| 636 | fn createParamDecl(self: &Parser) -> %&ast.NodeParamDecl { | 636 | fn createParamDecl(self: &Parser) -> %&ast.NodeParamDecl { |
| 637 | const node = try self.allocator.create(ast.NodeParamDecl); | 637 | const node = try self.allocator.create(ast.NodeParamDecl); |
| 638 | %defer self.allocator.destroy(node); | 638 | errdefer self.allocator.destroy(node); |
| 639 | 639 | ||
| 640 | *node = ast.NodeParamDecl { | 640 | *node = ast.NodeParamDecl { |
| 641 | .base = ast.Node {.id = ast.Node.Id.ParamDecl}, | 641 | .base = ast.Node {.id = ast.Node.Id.ParamDecl}, |
| ... | @@ -650,7 +650,7 @@ pub const Parser = struct { | ... | @@ -650,7 +650,7 @@ pub const Parser = struct { |
| 650 | 650 | ||
| 651 | fn createBlock(self: &Parser, begin_token: &const Token) -> %&ast.NodeBlock { | 651 | fn createBlock(self: &Parser, begin_token: &const Token) -> %&ast.NodeBlock { |
| 652 | const node = try self.allocator.create(ast.NodeBlock); | 652 | const node = try self.allocator.create(ast.NodeBlock); |
| 653 | %defer self.allocator.destroy(node); | 653 | errdefer self.allocator.destroy(node); |
| 654 | 654 | ||
| 655 | *node = ast.NodeBlock { | 655 | *node = ast.NodeBlock { |
| 656 | .base = ast.Node {.id = ast.Node.Id.Block}, | 656 | .base = ast.Node {.id = ast.Node.Id.Block}, |
| ... | @@ -663,7 +663,7 @@ pub const Parser = struct { | ... | @@ -663,7 +663,7 @@ pub const Parser = struct { |
| 663 | 663 | ||
| 664 | fn createInfixOp(self: &Parser, op_token: &const Token, op: &const ast.NodeInfixOp.InfixOp) -> %&ast.NodeInfixOp { | 664 | fn createInfixOp(self: &Parser, op_token: &const Token, op: &const ast.NodeInfixOp.InfixOp) -> %&ast.NodeInfixOp { |
| 665 | const node = try self.allocator.create(ast.NodeInfixOp); | 665 | const node = try self.allocator.create(ast.NodeInfixOp); |
| 666 | %defer self.allocator.destroy(node); | 666 | errdefer self.allocator.destroy(node); |
| 667 | 667 | ||
| 668 | *node = ast.NodeInfixOp { | 668 | *node = ast.NodeInfixOp { |
| 669 | .base = ast.Node {.id = ast.Node.Id.InfixOp}, | 669 | .base = ast.Node {.id = ast.Node.Id.InfixOp}, |
| ... | @@ -677,7 +677,7 @@ pub const Parser = struct { | ... | @@ -677,7 +677,7 @@ pub const Parser = struct { |
| 677 | 677 | ||
| 678 | fn createPrefixOp(self: &Parser, op_token: &const Token, op: &const ast.NodePrefixOp.PrefixOp) -> %&ast.NodePrefixOp { | 678 | fn createPrefixOp(self: &Parser, op_token: &const Token, op: &const ast.NodePrefixOp.PrefixOp) -> %&ast.NodePrefixOp { |
| 679 | const node = try self.allocator.create(ast.NodePrefixOp); | 679 | const node = try self.allocator.create(ast.NodePrefixOp); |
| 680 | %defer self.allocator.destroy(node); | 680 | errdefer self.allocator.destroy(node); |
| 681 | 681 | ||
| 682 | *node = ast.NodePrefixOp { | 682 | *node = ast.NodePrefixOp { |
| 683 | .base = ast.Node {.id = ast.Node.Id.PrefixOp}, | 683 | .base = ast.Node {.id = ast.Node.Id.PrefixOp}, |
| ... | @@ -690,7 +690,7 @@ pub const Parser = struct { | ... | @@ -690,7 +690,7 @@ pub const Parser = struct { |
| 690 | 690 | ||
| 691 | fn createIdentifier(self: &Parser, name_token: &const Token) -> %&ast.NodeIdentifier { | 691 | fn createIdentifier(self: &Parser, name_token: &const Token) -> %&ast.NodeIdentifier { |
| 692 | const node = try self.allocator.create(ast.NodeIdentifier); | 692 | const node = try self.allocator.create(ast.NodeIdentifier); |
| 693 | %defer self.allocator.destroy(node); | 693 | errdefer self.allocator.destroy(node); |
| 694 | 694 | ||
| 695 | *node = ast.NodeIdentifier { | 695 | *node = ast.NodeIdentifier { |
| 696 | .base = ast.Node {.id = ast.Node.Id.Identifier}, | 696 | .base = ast.Node {.id = ast.Node.Id.Identifier}, |
| ... | @@ -701,7 +701,7 @@ pub const Parser = struct { | ... | @@ -701,7 +701,7 @@ pub const Parser = struct { |
| 701 | 701 | ||
| 702 | fn createIntegerLiteral(self: &Parser, token: &const Token) -> %&ast.NodeIntegerLiteral { | 702 | fn createIntegerLiteral(self: &Parser, token: &const Token) -> %&ast.NodeIntegerLiteral { |
| 703 | const node = try self.allocator.create(ast.NodeIntegerLiteral); | 703 | const node = try self.allocator.create(ast.NodeIntegerLiteral); |
| 704 | %defer self.allocator.destroy(node); | 704 | errdefer self.allocator.destroy(node); |
| 705 | 705 | ||
| 706 | *node = ast.NodeIntegerLiteral { | 706 | *node = ast.NodeIntegerLiteral { |
| 707 | .base = ast.Node {.id = ast.Node.Id.IntegerLiteral}, | 707 | .base = ast.Node {.id = ast.Node.Id.IntegerLiteral}, |
| ... | @@ -712,7 +712,7 @@ pub const Parser = struct { | ... | @@ -712,7 +712,7 @@ pub const Parser = struct { |
| 712 | 712 | ||
| 713 | fn createFloatLiteral(self: &Parser, token: &const Token) -> %&ast.NodeFloatLiteral { | 713 | fn createFloatLiteral(self: &Parser, token: &const Token) -> %&ast.NodeFloatLiteral { |
| 714 | const node = try self.allocator.create(ast.NodeFloatLiteral); | 714 | const node = try self.allocator.create(ast.NodeFloatLiteral); |
| 715 | %defer self.allocator.destroy(node); | 715 | errdefer self.allocator.destroy(node); |
| 716 | 716 | ||
| 717 | *node = ast.NodeFloatLiteral { | 717 | *node = ast.NodeFloatLiteral { |
| 718 | .base = ast.Node {.id = ast.Node.Id.FloatLiteral}, | 718 | .base = ast.Node {.id = ast.Node.Id.FloatLiteral}, |
| ... | @@ -723,14 +723,14 @@ pub const Parser = struct { | ... | @@ -723,14 +723,14 @@ pub const Parser = struct { |
| 723 | 723 | ||
| 724 | fn createAttachIdentifier(self: &Parser, dest_ptr: &const DestPtr, name_token: &const Token) -> %&ast.NodeIdentifier { | 724 | fn createAttachIdentifier(self: &Parser, dest_ptr: &const DestPtr, name_token: &const Token) -> %&ast.NodeIdentifier { |
| 725 | const node = try self.createIdentifier(name_token); | 725 | const node = try self.createIdentifier(name_token); |
| 726 | %defer self.allocator.destroy(node); | 726 | errdefer self.allocator.destroy(node); |
| 727 | try dest_ptr.store(&node.base); | 727 | try dest_ptr.store(&node.base); |
| 728 | return node; | 728 | return node; |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | fn createAttachParamDecl(self: &Parser, list: &ArrayList(&ast.Node)) -> %&ast.NodeParamDecl { | 731 | fn createAttachParamDecl(self: &Parser, list: &ArrayList(&ast.Node)) -> %&ast.NodeParamDecl { |
| 732 | const node = try self.createParamDecl(); | 732 | const node = try self.createParamDecl(); |
| 733 | %defer self.allocator.destroy(node); | 733 | errdefer self.allocator.destroy(node); |
| 734 | try list.append(&node.base); | 734 | try list.append(&node.base); |
| 735 | return node; | 735 | return node; |
| 736 | } | 736 | } |
| ... | @@ -740,7 +740,7 @@ pub const Parser = struct { | ... | @@ -740,7 +740,7 @@ pub const Parser = struct { |
| 740 | inline_token: &const ?Token) -> %&ast.NodeFnProto | 740 | inline_token: &const ?Token) -> %&ast.NodeFnProto |
| 741 | { | 741 | { |
| 742 | const node = try self.createFnProto(fn_token, extern_token, cc_token, visib_token, inline_token); | 742 | const node = try self.createFnProto(fn_token, extern_token, cc_token, visib_token, inline_token); |
| 743 | %defer self.allocator.destroy(node); | 743 | errdefer self.allocator.destroy(node); |
| 744 | try list.append(&node.base); | 744 | try list.append(&node.base); |
| 745 | return node; | 745 | return node; |
| 746 | } | 746 | } |
| ... | @@ -749,7 +749,7 @@ pub const Parser = struct { | ... | @@ -749,7 +749,7 @@ pub const Parser = struct { |
| 749 | mut_token: &const Token, comptime_token: &const ?Token, extern_token: &const ?Token) -> %&ast.NodeVarDecl | 749 | mut_token: &const Token, comptime_token: &const ?Token, extern_token: &const ?Token) -> %&ast.NodeVarDecl |
| 750 | { | 750 | { |
| 751 | const node = try self.createVarDecl(visib_token, mut_token, comptime_token, extern_token); | 751 | const node = try self.createVarDecl(visib_token, mut_token, comptime_token, extern_token); |
| 752 | %defer self.allocator.destroy(node); | 752 | errdefer self.allocator.destroy(node); |
| 753 | try list.append(&node.base); | 753 | try list.append(&node.base); |
| 754 | return node; | 754 | return node; |
| 755 | } | 755 | } |
src/parser.cpp+5-10| ... | @@ -1495,7 +1495,7 @@ static AstNode *ast_parse_break_expr(ParseContext *pc, size_t *token_index) { | ... | @@ -1495,7 +1495,7 @@ static AstNode *ast_parse_break_expr(ParseContext *pc, size_t *token_index) { |
| 1495 | } | 1495 | } |
| 1496 | 1496 | ||
| 1497 | /* | 1497 | /* |
| 1498 | Defer(body) = option("%") "defer" body | 1498 | Defer(body) = ("defer" | "errdefer") body |
| 1499 | */ | 1499 | */ |
| 1500 | static AstNode *ast_parse_defer_expr(ParseContext *pc, size_t *token_index) { | 1500 | static AstNode *ast_parse_defer_expr(ParseContext *pc, size_t *token_index) { |
| 1501 | Token *token = &pc->tokens->at(*token_index); | 1501 | Token *token = &pc->tokens->at(*token_index); |
| ... | @@ -1503,15 +1503,10 @@ static AstNode *ast_parse_defer_expr(ParseContext *pc, size_t *token_index) { | ... | @@ -1503,15 +1503,10 @@ static AstNode *ast_parse_defer_expr(ParseContext *pc, size_t *token_index) { |
| 1503 | NodeType node_type; | 1503 | NodeType node_type; |
| 1504 | ReturnKind kind; | 1504 | ReturnKind kind; |
| 1505 | 1505 | ||
| 1506 | if (token->id == TokenIdPercent) { | 1506 | if (token->id == TokenIdKeywordErrdefer) { |
| 1507 | Token *next_token = &pc->tokens->at(*token_index + 1); | 1507 | kind = ReturnKindError; |
| 1508 | if (next_token->id == TokenIdKeywordDefer) { | 1508 | node_type = NodeTypeDefer; |
| 1509 | kind = ReturnKindError; | 1509 | *token_index += 1; |
| 1510 | node_type = NodeTypeDefer; | ||
| 1511 | *token_index += 2; | ||
| 1512 | } else { | ||
| 1513 | return nullptr; | ||
| 1514 | } | ||
| 1515 | } else if (token->id == TokenIdKeywordDefer) { | 1510 | } else if (token->id == TokenIdKeywordDefer) { |
| 1516 | kind = ReturnKindUnconditional; | 1511 | kind = ReturnKindUnconditional; |
| 1517 | node_type = NodeTypeDefer; | 1512 | node_type = NodeTypeDefer; |
src/tokenizer.cpp+2| ... | @@ -118,6 +118,7 @@ static const struct ZigKeyword zig_keywords[] = { | ... | @@ -118,6 +118,7 @@ static const struct ZigKeyword zig_keywords[] = { |
| 118 | {"defer", TokenIdKeywordDefer}, | 118 | {"defer", TokenIdKeywordDefer}, |
| 119 | {"else", TokenIdKeywordElse}, | 119 | {"else", TokenIdKeywordElse}, |
| 120 | {"enum", TokenIdKeywordEnum}, | 120 | {"enum", TokenIdKeywordEnum}, |
| 121 | {"errdefer", TokenIdKeywordErrdefer}, | ||
| 121 | {"error", TokenIdKeywordError}, | 122 | {"error", TokenIdKeywordError}, |
| 122 | {"export", TokenIdKeywordExport}, | 123 | {"export", TokenIdKeywordExport}, |
| 123 | {"extern", TokenIdKeywordExtern}, | 124 | {"extern", TokenIdKeywordExtern}, |
| ... | @@ -1514,6 +1515,7 @@ const char * token_name(TokenId id) { | ... | @@ -1514,6 +1515,7 @@ const char * token_name(TokenId id) { |
| 1514 | case TokenIdKeywordDefer: return "defer"; | 1515 | case TokenIdKeywordDefer: return "defer"; |
| 1515 | case TokenIdKeywordElse: return "else"; | 1516 | case TokenIdKeywordElse: return "else"; |
| 1516 | case TokenIdKeywordEnum: return "enum"; | 1517 | case TokenIdKeywordEnum: return "enum"; |
| 1518 | case TokenIdKeywordErrdefer: return "errdefer"; | ||
| 1517 | case TokenIdKeywordError: return "error"; | 1519 | case TokenIdKeywordError: return "error"; |
| 1518 | case TokenIdKeywordExport: return "export"; | 1520 | case TokenIdKeywordExport: return "export"; |
| 1519 | case TokenIdKeywordExtern: return "extern"; | 1521 | case TokenIdKeywordExtern: return "extern"; |
src/tokenizer.hpp+1| ... | @@ -57,6 +57,7 @@ enum TokenId { | ... | @@ -57,6 +57,7 @@ enum TokenId { |
| 57 | TokenIdKeywordDefer, | 57 | TokenIdKeywordDefer, |
| 58 | TokenIdKeywordElse, | 58 | TokenIdKeywordElse, |
| 59 | TokenIdKeywordEnum, | 59 | TokenIdKeywordEnum, |
| 60 | TokenIdKeywordErrdefer, | ||
| 60 | TokenIdKeywordError, | 61 | TokenIdKeywordError, |
| 61 | TokenIdKeywordExport, | 62 | TokenIdKeywordExport, |
| 62 | TokenIdKeywordExtern, | 63 | TokenIdKeywordExtern, |
std/buf_map.zig+3-3| ... | @@ -30,14 +30,14 @@ pub const BufMap = struct { | ... | @@ -30,14 +30,14 @@ pub const BufMap = struct { |
| 30 | pub fn set(self: &BufMap, key: []const u8, value: []const u8) -> %void { | 30 | pub fn set(self: &BufMap, key: []const u8, value: []const u8) -> %void { |
| 31 | if (self.hash_map.get(key)) |entry| { | 31 | if (self.hash_map.get(key)) |entry| { |
| 32 | const value_copy = try self.copy(value); | 32 | const value_copy = try self.copy(value); |
| 33 | %defer self.free(value_copy); | 33 | errdefer self.free(value_copy); |
| 34 | _ = try self.hash_map.put(key, value_copy); | 34 | _ = try self.hash_map.put(key, value_copy); |
| 35 | self.free(entry.value); | 35 | self.free(entry.value); |
| 36 | } else { | 36 | } else { |
| 37 | const key_copy = try self.copy(key); | 37 | const key_copy = try self.copy(key); |
| 38 | %defer self.free(key_copy); | 38 | errdefer self.free(key_copy); |
| 39 | const value_copy = try self.copy(value); | 39 | const value_copy = try self.copy(value); |
| 40 | %defer self.free(value_copy); | 40 | errdefer self.free(value_copy); |
| 41 | _ = try self.hash_map.put(key_copy, value_copy); | 41 | _ = try self.hash_map.put(key_copy, value_copy); |
| 42 | } | 42 | } |
| 43 | } | 43 | } |
std/buf_set.zig+1-1| ... | @@ -27,7 +27,7 @@ pub const BufSet = struct { | ... | @@ -27,7 +27,7 @@ pub const BufSet = struct { |
| 27 | pub fn put(self: &BufSet, key: []const u8) -> %void { | 27 | pub fn put(self: &BufSet, key: []const u8) -> %void { |
| 28 | if (self.hash_map.get(key) == null) { | 28 | if (self.hash_map.get(key) == null) { |
| 29 | const key_copy = try self.copy(key); | 29 | const key_copy = try self.copy(key); |
| 30 | %defer self.free(key_copy); | 30 | errdefer self.free(key_copy); |
| 31 | _ = try self.hash_map.put(key_copy, {}); | 31 | _ = try self.hash_map.put(key_copy, {}); |
| 32 | } | 32 | } |
| 33 | } | 33 | } |
std/cstr.zig+1-1| ... | @@ -71,7 +71,7 @@ pub const NullTerminated2DArray = struct { | ... | @@ -71,7 +71,7 @@ pub const NullTerminated2DArray = struct { |
| 71 | byte_count += index_size; | 71 | byte_count += index_size; |
| 72 | 72 | ||
| 73 | const buf = try allocator.alignedAlloc(u8, @alignOf(?&u8), byte_count); | 73 | const buf = try allocator.alignedAlloc(u8, @alignOf(?&u8), byte_count); |
| 74 | %defer allocator.free(buf); | 74 | errdefer allocator.free(buf); |
| 75 | 75 | ||
| 76 | var write_index = index_size; | 76 | var write_index = index_size; |
| 77 | const index_buf = ([]?&u8)(buf); | 77 | const index_buf = ([]?&u8)(buf); |
std/debug/index.zig+4-4| ... | @@ -248,10 +248,10 @@ pub fn openSelfDebugInfo(allocator: &mem.Allocator) -> %&ElfStackTrace { | ... | @@ -248,10 +248,10 @@ pub fn openSelfDebugInfo(allocator: &mem.Allocator) -> %&ElfStackTrace { |
| 248 | .compile_unit_list = ArrayList(CompileUnit).init(allocator), | 248 | .compile_unit_list = ArrayList(CompileUnit).init(allocator), |
| 249 | }; | 249 | }; |
| 250 | st.self_exe_file = try os.openSelfExe(); | 250 | st.self_exe_file = try os.openSelfExe(); |
| 251 | %defer st.self_exe_file.close(); | 251 | errdefer st.self_exe_file.close(); |
| 252 | 252 | ||
| 253 | try st.elf.openFile(allocator, &st.self_exe_file); | 253 | try st.elf.openFile(allocator, &st.self_exe_file); |
| 254 | %defer st.elf.close(); | 254 | errdefer st.elf.close(); |
| 255 | 255 | ||
| 256 | st.debug_info = (try st.elf.findSection(".debug_info")) ?? return error.MissingDebugInfo; | 256 | st.debug_info = (try st.elf.findSection(".debug_info")) ?? return error.MissingDebugInfo; |
| 257 | st.debug_abbrev = (try st.elf.findSection(".debug_abbrev")) ?? return error.MissingDebugInfo; | 257 | st.debug_abbrev = (try st.elf.findSection(".debug_abbrev")) ?? return error.MissingDebugInfo; |
| ... | @@ -524,7 +524,7 @@ const LineNumberProgram = struct { | ... | @@ -524,7 +524,7 @@ const LineNumberProgram = struct { |
| 524 | return error.InvalidDebugInfo; | 524 | return error.InvalidDebugInfo; |
| 525 | } else self.include_dirs[file_entry.dir_index]; | 525 | } else self.include_dirs[file_entry.dir_index]; |
| 526 | const file_name = try os.path.join(self.file_entries.allocator, dir_name, file_entry.file_name); | 526 | const file_name = try os.path.join(self.file_entries.allocator, dir_name, file_entry.file_name); |
| 527 | %defer self.file_entries.allocator.free(file_name); | 527 | errdefer self.file_entries.allocator.free(file_name); |
| 528 | return LineInfo { | 528 | return LineInfo { |
| 529 | .line = if (self.prev_line >= 0) usize(self.prev_line) else 0, | 529 | .line = if (self.prev_line >= 0) usize(self.prev_line) else 0, |
| 530 | .column = self.prev_column, | 530 | .column = self.prev_column, |
| ... | @@ -563,7 +563,7 @@ fn getString(st: &ElfStackTrace, offset: u64) -> %[]u8 { | ... | @@ -563,7 +563,7 @@ fn getString(st: &ElfStackTrace, offset: u64) -> %[]u8 { |
| 563 | 563 | ||
| 564 | fn readAllocBytes(allocator: &mem.Allocator, in_stream: &io.InStream, size: usize) -> %[]u8 { | 564 | fn readAllocBytes(allocator: &mem.Allocator, in_stream: &io.InStream, size: usize) -> %[]u8 { |
| 565 | const buf = try global_allocator.alloc(u8, size); | 565 | const buf = try global_allocator.alloc(u8, size); |
| 566 | %defer global_allocator.free(buf); | 566 | errdefer global_allocator.free(buf); |
| 567 | if ((try in_stream.read(buf)) < size) return error.EndOfFile; | 567 | if ((try in_stream.read(buf)) < size) return error.EndOfFile; |
| 568 | return buf; | 568 | return buf; |
| 569 | } | 569 | } |
std/elf.zig+1-1| ... | @@ -183,7 +183,7 @@ pub const Elf = struct { | ... | @@ -183,7 +183,7 @@ pub const Elf = struct { |
| 183 | try elf.in_file.seekTo(elf.section_header_offset); | 183 | try elf.in_file.seekTo(elf.section_header_offset); |
| 184 | 184 | ||
| 185 | elf.section_headers = try elf.allocator.alloc(SectionHeader, sh_entry_count); | 185 | elf.section_headers = try elf.allocator.alloc(SectionHeader, sh_entry_count); |
| 186 | %defer elf.allocator.free(elf.section_headers); | 186 | errdefer elf.allocator.free(elf.section_headers); |
| 187 | 187 | ||
| 188 | if (elf.is_64) { | 188 | if (elf.is_64) { |
| 189 | if (sh_entry_size != 64) return error.InvalidFormat; | 189 | if (sh_entry_size != 64) return error.InvalidFormat; |
std/io.zig+1-1| ... | @@ -550,7 +550,7 @@ pub fn readFileAllocExtra(path: []const u8, allocator: &mem.Allocator, extra_len | ... | @@ -550,7 +550,7 @@ pub fn readFileAllocExtra(path: []const u8, allocator: &mem.Allocator, extra_len |
| 550 | 550 | ||
| 551 | const size = try file.getEndPos(); | 551 | const size = try file.getEndPos(); |
| 552 | const buf = try allocator.alloc(u8, size + extra_len); | 552 | const buf = try allocator.alloc(u8, size + extra_len); |
| 553 | %defer allocator.free(buf); | 553 | errdefer allocator.free(buf); |
| 554 | 554 | ||
| 555 | var adapter = FileInStream.init(&file); | 555 | var adapter = FileInStream.init(&file); |
| 556 | try adapter.stream.readNoEof(buf[0..size]); | 556 | try adapter.stream.readNoEof(buf[0..size]); |
std/mem.zig+1-1| ... | @@ -440,7 +440,7 @@ pub fn join(allocator: &Allocator, sep: u8, strings: ...) -> %[]u8 { | ... | @@ -440,7 +440,7 @@ pub fn join(allocator: &Allocator, sep: u8, strings: ...) -> %[]u8 { |
| 440 | } | 440 | } |
| 441 | 441 | ||
| 442 | const buf = try allocator.alloc(u8, total_strings_len); | 442 | const buf = try allocator.alloc(u8, total_strings_len); |
| 443 | %defer allocator.free(buf); | 443 | errdefer allocator.free(buf); |
| 444 | 444 | ||
| 445 | var buf_index: usize = 0; | 445 | var buf_index: usize = 0; |
| 446 | comptime var string_i = 0; | 446 | comptime var string_i = 0; |
std/os/child_process.zig+10-10| ... | @@ -76,7 +76,7 @@ pub const ChildProcess = struct { | ... | @@ -76,7 +76,7 @@ pub const ChildProcess = struct { |
| 76 | /// On success must call deinit. | 76 | /// On success must call deinit. |
| 77 | pub fn init(argv: []const []const u8, allocator: &mem.Allocator) -> %&ChildProcess { | 77 | pub fn init(argv: []const []const u8, allocator: &mem.Allocator) -> %&ChildProcess { |
| 78 | const child = try allocator.create(ChildProcess); | 78 | const child = try allocator.create(ChildProcess); |
| 79 | %defer allocator.destroy(child); | 79 | errdefer allocator.destroy(child); |
| 80 | 80 | ||
| 81 | *child = ChildProcess { | 81 | *child = ChildProcess { |
| 82 | .allocator = allocator, | 82 | .allocator = allocator, |
| ... | @@ -336,13 +336,13 @@ pub const ChildProcess = struct { | ... | @@ -336,13 +336,13 @@ pub const ChildProcess = struct { |
| 336 | install_SIGCHLD_handler(); | 336 | install_SIGCHLD_handler(); |
| 337 | 337 | ||
| 338 | const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try makePipe() else undefined; | 338 | const stdin_pipe = if (self.stdin_behavior == StdIo.Pipe) try makePipe() else undefined; |
| 339 | %defer if (self.stdin_behavior == StdIo.Pipe) { destroyPipe(stdin_pipe); }; | 339 | errdefer if (self.stdin_behavior == StdIo.Pipe) { destroyPipe(stdin_pipe); }; |
| 340 | 340 | ||
| 341 | const stdout_pipe = if (self.stdout_behavior == StdIo.Pipe) try makePipe() else undefined; | 341 | const stdout_pipe = if (self.stdout_behavior == StdIo.Pipe) try makePipe() else undefined; |
| 342 | %defer if (self.stdout_behavior == StdIo.Pipe) { destroyPipe(stdout_pipe); }; | 342 | errdefer if (self.stdout_behavior == StdIo.Pipe) { destroyPipe(stdout_pipe); }; |
| 343 | 343 | ||
| 344 | const stderr_pipe = if (self.stderr_behavior == StdIo.Pipe) try makePipe() else undefined; | 344 | const stderr_pipe = if (self.stderr_behavior == StdIo.Pipe) try makePipe() else undefined; |
| 345 | %defer if (self.stderr_behavior == StdIo.Pipe) { destroyPipe(stderr_pipe); }; | 345 | errdefer if (self.stderr_behavior == StdIo.Pipe) { destroyPipe(stderr_pipe); }; |
| 346 | 346 | ||
| 347 | const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore); | 347 | const any_ignore = (self.stdin_behavior == StdIo.Ignore or self.stdout_behavior == StdIo.Ignore or self.stderr_behavior == StdIo.Ignore); |
| 348 | const dev_null_fd = if (any_ignore) | 348 | const dev_null_fd = if (any_ignore) |
| ... | @@ -367,7 +367,7 @@ pub const ChildProcess = struct { | ... | @@ -367,7 +367,7 @@ pub const ChildProcess = struct { |
| 367 | // This pipe is used to communicate errors between the time of fork | 367 | // This pipe is used to communicate errors between the time of fork |
| 368 | // and execve from the child process to the parent process. | 368 | // and execve from the child process to the parent process. |
| 369 | const err_pipe = try makePipe(); | 369 | const err_pipe = try makePipe(); |
| 370 | %defer destroyPipe(err_pipe); | 370 | errdefer destroyPipe(err_pipe); |
| 371 | 371 | ||
| 372 | block_SIGCHLD(); | 372 | block_SIGCHLD(); |
| 373 | const pid_result = posix.fork(); | 373 | const pid_result = posix.fork(); |
| ... | @@ -479,7 +479,7 @@ pub const ChildProcess = struct { | ... | @@ -479,7 +479,7 @@ pub const ChildProcess = struct { |
| 479 | g_hChildStd_IN_Rd = null; | 479 | g_hChildStd_IN_Rd = null; |
| 480 | }, | 480 | }, |
| 481 | } | 481 | } |
| 482 | %defer if (self.stdin_behavior == StdIo.Pipe) { windowsDestroyPipe(g_hChildStd_IN_Rd, g_hChildStd_IN_Wr); }; | 482 | errdefer if (self.stdin_behavior == StdIo.Pipe) { windowsDestroyPipe(g_hChildStd_IN_Rd, g_hChildStd_IN_Wr); }; |
| 483 | 483 | ||
| 484 | var g_hChildStd_OUT_Rd: ?windows.HANDLE = null; | 484 | var g_hChildStd_OUT_Rd: ?windows.HANDLE = null; |
| 485 | var g_hChildStd_OUT_Wr: ?windows.HANDLE = null; | 485 | var g_hChildStd_OUT_Wr: ?windows.HANDLE = null; |
| ... | @@ -497,7 +497,7 @@ pub const ChildProcess = struct { | ... | @@ -497,7 +497,7 @@ pub const ChildProcess = struct { |
| 497 | g_hChildStd_OUT_Wr = null; | 497 | g_hChildStd_OUT_Wr = null; |
| 498 | }, | 498 | }, |
| 499 | } | 499 | } |
| 500 | %defer if (self.stdin_behavior == StdIo.Pipe) { windowsDestroyPipe(g_hChildStd_OUT_Rd, g_hChildStd_OUT_Wr); }; | 500 | errdefer if (self.stdin_behavior == StdIo.Pipe) { windowsDestroyPipe(g_hChildStd_OUT_Rd, g_hChildStd_OUT_Wr); }; |
| 501 | 501 | ||
| 502 | var g_hChildStd_ERR_Rd: ?windows.HANDLE = null; | 502 | var g_hChildStd_ERR_Rd: ?windows.HANDLE = null; |
| 503 | var g_hChildStd_ERR_Wr: ?windows.HANDLE = null; | 503 | var g_hChildStd_ERR_Wr: ?windows.HANDLE = null; |
| ... | @@ -515,7 +515,7 @@ pub const ChildProcess = struct { | ... | @@ -515,7 +515,7 @@ pub const ChildProcess = struct { |
| 515 | g_hChildStd_ERR_Wr = null; | 515 | g_hChildStd_ERR_Wr = null; |
| 516 | }, | 516 | }, |
| 517 | } | 517 | } |
| 518 | %defer if (self.stdin_behavior == StdIo.Pipe) { windowsDestroyPipe(g_hChildStd_ERR_Rd, g_hChildStd_ERR_Wr); }; | 518 | errdefer if (self.stdin_behavior == StdIo.Pipe) { windowsDestroyPipe(g_hChildStd_ERR_Rd, g_hChildStd_ERR_Wr); }; |
| 519 | 519 | ||
| 520 | const cmd_line = try windowsCreateCommandLine(self.allocator, self.argv); | 520 | const cmd_line = try windowsCreateCommandLine(self.allocator, self.argv); |
| 521 | defer self.allocator.free(cmd_line); | 521 | defer self.allocator.free(cmd_line); |
| ... | @@ -722,7 +722,7 @@ fn windowsMakePipeIn(rd: &?windows.HANDLE, wr: &?windows.HANDLE, sattr: &const S | ... | @@ -722,7 +722,7 @@ fn windowsMakePipeIn(rd: &?windows.HANDLE, wr: &?windows.HANDLE, sattr: &const S |
| 722 | var rd_h: windows.HANDLE = undefined; | 722 | var rd_h: windows.HANDLE = undefined; |
| 723 | var wr_h: windows.HANDLE = undefined; | 723 | var wr_h: windows.HANDLE = undefined; |
| 724 | try windowsMakePipe(&rd_h, &wr_h, sattr); | 724 | try windowsMakePipe(&rd_h, &wr_h, sattr); |
| 725 | %defer windowsDestroyPipe(rd_h, wr_h); | 725 | errdefer windowsDestroyPipe(rd_h, wr_h); |
| 726 | try windowsSetHandleInfo(wr_h, windows.HANDLE_FLAG_INHERIT, 0); | 726 | try windowsSetHandleInfo(wr_h, windows.HANDLE_FLAG_INHERIT, 0); |
| 727 | *rd = rd_h; | 727 | *rd = rd_h; |
| 728 | *wr = wr_h; | 728 | *wr = wr_h; |
| ... | @@ -732,7 +732,7 @@ fn windowsMakePipeOut(rd: &?windows.HANDLE, wr: &?windows.HANDLE, sattr: &const | ... | @@ -732,7 +732,7 @@ fn windowsMakePipeOut(rd: &?windows.HANDLE, wr: &?windows.HANDLE, sattr: &const |
| 732 | var rd_h: windows.HANDLE = undefined; | 732 | var rd_h: windows.HANDLE = undefined; |
| 733 | var wr_h: windows.HANDLE = undefined; | 733 | var wr_h: windows.HANDLE = undefined; |
| 734 | try windowsMakePipe(&rd_h, &wr_h, sattr); | 734 | try windowsMakePipe(&rd_h, &wr_h, sattr); |
| 735 | %defer windowsDestroyPipe(rd_h, wr_h); | 735 | errdefer windowsDestroyPipe(rd_h, wr_h); |
| 736 | try windowsSetHandleInfo(rd_h, windows.HANDLE_FLAG_INHERIT, 0); | 736 | try windowsSetHandleInfo(rd_h, windows.HANDLE_FLAG_INHERIT, 0); |
| 737 | *rd = rd_h; | 737 | *rd = rd_h; |
| 738 | *wr = wr_h; | 738 | *wr = wr_h; |
std/os/index.zig+12-12| ... | @@ -311,7 +311,7 @@ pub fn createNullDelimitedEnvMap(allocator: &Allocator, env_map: &const BufMap) | ... | @@ -311,7 +311,7 @@ pub fn createNullDelimitedEnvMap(allocator: &Allocator, env_map: &const BufMap) |
| 311 | const envp_count = env_map.count(); | 311 | const envp_count = env_map.count(); |
| 312 | const envp_buf = try allocator.alloc(?&u8, envp_count + 1); | 312 | const envp_buf = try allocator.alloc(?&u8, envp_count + 1); |
| 313 | mem.set(?&u8, envp_buf, null); | 313 | mem.set(?&u8, envp_buf, null); |
| 314 | %defer freeNullDelimitedEnvMap(allocator, envp_buf); | 314 | errdefer freeNullDelimitedEnvMap(allocator, envp_buf); |
| 315 | { | 315 | { |
| 316 | var it = env_map.iterator(); | 316 | var it = env_map.iterator(); |
| 317 | var i: usize = 0; | 317 | var i: usize = 0; |
| ... | @@ -421,7 +421,7 @@ pub var posix_environ_raw: []&u8 = undefined; | ... | @@ -421,7 +421,7 @@ pub var posix_environ_raw: []&u8 = undefined; |
| 421 | /// Caller must free result when done. | 421 | /// Caller must free result when done. |
| 422 | pub fn getEnvMap(allocator: &Allocator) -> %BufMap { | 422 | pub fn getEnvMap(allocator: &Allocator) -> %BufMap { |
| 423 | var result = BufMap.init(allocator); | 423 | var result = BufMap.init(allocator); |
| 424 | %defer result.deinit(); | 424 | errdefer result.deinit(); |
| 425 | 425 | ||
| 426 | if (is_windows) { | 426 | if (is_windows) { |
| 427 | const ptr = windows.GetEnvironmentStringsA() ?? return error.OutOfMemory; | 427 | const ptr = windows.GetEnvironmentStringsA() ?? return error.OutOfMemory; |
| ... | @@ -489,7 +489,7 @@ pub fn getEnvVarOwned(allocator: &mem.Allocator, key: []const u8) -> %[]u8 { | ... | @@ -489,7 +489,7 @@ pub fn getEnvVarOwned(allocator: &mem.Allocator, key: []const u8) -> %[]u8 { |
| 489 | defer allocator.free(key_with_null); | 489 | defer allocator.free(key_with_null); |
| 490 | 490 | ||
| 491 | var buf = try allocator.alloc(u8, 256); | 491 | var buf = try allocator.alloc(u8, 256); |
| 492 | %defer allocator.free(buf); | 492 | errdefer allocator.free(buf); |
| 493 | 493 | ||
| 494 | while (true) { | 494 | while (true) { |
| 495 | const windows_buf_len = try math.cast(windows.DWORD, buf.len); | 495 | const windows_buf_len = try math.cast(windows.DWORD, buf.len); |
| ... | @@ -521,7 +521,7 @@ pub fn getCwd(allocator: &Allocator) -> %[]u8 { | ... | @@ -521,7 +521,7 @@ pub fn getCwd(allocator: &Allocator) -> %[]u8 { |
| 521 | switch (builtin.os) { | 521 | switch (builtin.os) { |
| 522 | Os.windows => { | 522 | Os.windows => { |
| 523 | var buf = try allocator.alloc(u8, 256); | 523 | var buf = try allocator.alloc(u8, 256); |
| 524 | %defer allocator.free(buf); | 524 | errdefer allocator.free(buf); |
| 525 | 525 | ||
| 526 | while (true) { | 526 | while (true) { |
| 527 | const result = windows.GetCurrentDirectoryA(windows.WORD(buf.len), buf.ptr); | 527 | const result = windows.GetCurrentDirectoryA(windows.WORD(buf.len), buf.ptr); |
| ... | @@ -543,7 +543,7 @@ pub fn getCwd(allocator: &Allocator) -> %[]u8 { | ... | @@ -543,7 +543,7 @@ pub fn getCwd(allocator: &Allocator) -> %[]u8 { |
| 543 | }, | 543 | }, |
| 544 | else => { | 544 | else => { |
| 545 | var buf = try allocator.alloc(u8, 1024); | 545 | var buf = try allocator.alloc(u8, 1024); |
| 546 | %defer allocator.free(buf); | 546 | errdefer allocator.free(buf); |
| 547 | while (true) { | 547 | while (true) { |
| 548 | const err = posix.getErrno(posix.getcwd(buf.ptr, buf.len)); | 548 | const err = posix.getErrno(posix.getcwd(buf.ptr, buf.len)); |
| 549 | if (err == posix.ERANGE) { | 549 | if (err == posix.ERANGE) { |
| ... | @@ -724,7 +724,7 @@ pub fn copyFileMode(allocator: &Allocator, source_path: []const u8, dest_path: [ | ... | @@ -724,7 +724,7 @@ pub fn copyFileMode(allocator: &Allocator, source_path: []const u8, dest_path: [ |
| 724 | 724 | ||
| 725 | var out_file = try io.File.openWriteMode(tmp_path, mode, allocator); | 725 | var out_file = try io.File.openWriteMode(tmp_path, mode, allocator); |
| 726 | defer out_file.close(); | 726 | defer out_file.close(); |
| 727 | %defer _ = deleteFile(allocator, tmp_path); | 727 | errdefer _ = deleteFile(allocator, tmp_path); |
| 728 | 728 | ||
| 729 | var in_file = try io.File.openRead(source_path, allocator); | 729 | var in_file = try io.File.openRead(source_path, allocator); |
| 730 | defer in_file.close(); | 730 | defer in_file.close(); |
| ... | @@ -1074,7 +1074,7 @@ pub fn readLink(allocator: &Allocator, pathname: []const u8) -> %[]u8 { | ... | @@ -1074,7 +1074,7 @@ pub fn readLink(allocator: &Allocator, pathname: []const u8) -> %[]u8 { |
| 1074 | path_buf[pathname.len] = 0; | 1074 | path_buf[pathname.len] = 0; |
| 1075 | 1075 | ||
| 1076 | var result_buf = try allocator.alloc(u8, 1024); | 1076 | var result_buf = try allocator.alloc(u8, 1024); |
| 1077 | %defer allocator.free(result_buf); | 1077 | errdefer allocator.free(result_buf); |
| 1078 | while (true) { | 1078 | while (true) { |
| 1079 | const ret_val = posix.readlink(path_buf.ptr, result_buf.ptr, result_buf.len); | 1079 | const ret_val = posix.readlink(path_buf.ptr, result_buf.ptr, result_buf.len); |
| 1080 | const err = posix.getErrno(ret_val); | 1080 | const err = posix.getErrno(ret_val); |
| ... | @@ -1443,7 +1443,7 @@ pub fn argsAlloc(allocator: &mem.Allocator) -> %[]const []u8 { | ... | @@ -1443,7 +1443,7 @@ pub fn argsAlloc(allocator: &mem.Allocator) -> %[]const []u8 { |
| 1443 | const slice_list_bytes = try math.mul(usize, @sizeOf([]u8), slice_sizes.len); | 1443 | const slice_list_bytes = try math.mul(usize, @sizeOf([]u8), slice_sizes.len); |
| 1444 | const total_bytes = try math.add(usize, slice_list_bytes, contents_slice.len); | 1444 | const total_bytes = try math.add(usize, slice_list_bytes, contents_slice.len); |
| 1445 | const buf = try allocator.alignedAlloc(u8, @alignOf([]u8), total_bytes); | 1445 | const buf = try allocator.alignedAlloc(u8, @alignOf([]u8), total_bytes); |
| 1446 | %defer allocator.free(buf); | 1446 | errdefer allocator.free(buf); |
| 1447 | 1447 | ||
| 1448 | const result_slice_list = ([][]u8)(buf[0..slice_list_bytes]); | 1448 | const result_slice_list = ([][]u8)(buf[0..slice_list_bytes]); |
| 1449 | const result_contents = buf[slice_list_bytes..]; | 1449 | const result_contents = buf[slice_list_bytes..]; |
| ... | @@ -1556,7 +1556,7 @@ pub fn selfExePath(allocator: &mem.Allocator) -> %[]u8 { | ... | @@ -1556,7 +1556,7 @@ pub fn selfExePath(allocator: &mem.Allocator) -> %[]u8 { |
| 1556 | }, | 1556 | }, |
| 1557 | Os.windows => { | 1557 | Os.windows => { |
| 1558 | var out_path = try Buffer.initSize(allocator, 0xff); | 1558 | var out_path = try Buffer.initSize(allocator, 0xff); |
| 1559 | %defer out_path.deinit(); | 1559 | errdefer out_path.deinit(); |
| 1560 | while (true) { | 1560 | while (true) { |
| 1561 | const dword_len = try math.cast(windows.DWORD, out_path.len()); | 1561 | const dword_len = try math.cast(windows.DWORD, out_path.len()); |
| 1562 | const copied_amt = windows.GetModuleFileNameA(null, out_path.ptr(), dword_len); | 1562 | const copied_amt = windows.GetModuleFileNameA(null, out_path.ptr(), dword_len); |
| ... | @@ -1579,7 +1579,7 @@ pub fn selfExePath(allocator: &mem.Allocator) -> %[]u8 { | ... | @@ -1579,7 +1579,7 @@ pub fn selfExePath(allocator: &mem.Allocator) -> %[]u8 { |
| 1579 | const ret1 = c._NSGetExecutablePath(undefined, &u32_len); | 1579 | const ret1 = c._NSGetExecutablePath(undefined, &u32_len); |
| 1580 | assert(ret1 != 0); | 1580 | assert(ret1 != 0); |
| 1581 | const bytes = try allocator.alloc(u8, u32_len); | 1581 | const bytes = try allocator.alloc(u8, u32_len); |
| 1582 | %defer allocator.free(bytes); | 1582 | errdefer allocator.free(bytes); |
| 1583 | const ret2 = c._NSGetExecutablePath(bytes.ptr, &u32_len); | 1583 | const ret2 = c._NSGetExecutablePath(bytes.ptr, &u32_len); |
| 1584 | assert(ret2 == 0); | 1584 | assert(ret2 == 0); |
| 1585 | return bytes; | 1585 | return bytes; |
| ... | @@ -1598,13 +1598,13 @@ pub fn selfExeDirPath(allocator: &mem.Allocator) -> %[]u8 { | ... | @@ -1598,13 +1598,13 @@ pub fn selfExeDirPath(allocator: &mem.Allocator) -> %[]u8 { |
| 1598 | // This path cannot be opened, but it's valid for determining the directory | 1598 | // This path cannot be opened, but it's valid for determining the directory |
| 1599 | // the executable was in when it was run. | 1599 | // the executable was in when it was run. |
| 1600 | const full_exe_path = try readLink(allocator, "/proc/self/exe"); | 1600 | const full_exe_path = try readLink(allocator, "/proc/self/exe"); |
| 1601 | %defer allocator.free(full_exe_path); | 1601 | errdefer allocator.free(full_exe_path); |
| 1602 | const dir = path.dirname(full_exe_path); | 1602 | const dir = path.dirname(full_exe_path); |
| 1603 | return allocator.shrink(u8, full_exe_path, dir.len); | 1603 | return allocator.shrink(u8, full_exe_path, dir.len); |
| 1604 | }, | 1604 | }, |
| 1605 | Os.windows, Os.macosx, Os.ios => { | 1605 | Os.windows, Os.macosx, Os.ios => { |
| 1606 | const self_exe_path = try selfExePath(allocator); | 1606 | const self_exe_path = try selfExePath(allocator); |
| 1607 | %defer allocator.free(self_exe_path); | 1607 | errdefer allocator.free(self_exe_path); |
| 1608 | const dirname = os.path.dirname(self_exe_path); | 1608 | const dirname = os.path.dirname(self_exe_path); |
| 1609 | return allocator.shrink(u8, self_exe_path, dirname.len); | 1609 | return allocator.shrink(u8, self_exe_path, dirname.len); |
| 1610 | }, | 1610 | }, |
std/os/path.zig+6-6| ... | @@ -468,7 +468,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8 | ... | @@ -468,7 +468,7 @@ pub fn resolveWindows(allocator: &Allocator, paths: []const []const u8) -> %[]u8 |
| 468 | } | 468 | } |
| 469 | have_drive_kind = parsed_cwd.kind; | 469 | have_drive_kind = parsed_cwd.kind; |
| 470 | } | 470 | } |
| 471 | %defer allocator.free(result); | 471 | errdefer allocator.free(result); |
| 472 | 472 | ||
| 473 | // Now we know the disk designator to use, if any, and what kind it is. And our result | 473 | // Now we know the disk designator to use, if any, and what kind it is. And our result |
| 474 | // is big enough to append all the paths to. | 474 | // is big enough to append all the paths to. |
| ... | @@ -551,7 +551,7 @@ pub fn resolvePosix(allocator: &Allocator, paths: []const []const u8) -> %[]u8 { | ... | @@ -551,7 +551,7 @@ pub fn resolvePosix(allocator: &Allocator, paths: []const []const u8) -> %[]u8 { |
| 551 | mem.copy(u8, result, cwd); | 551 | mem.copy(u8, result, cwd); |
| 552 | result_index += cwd.len; | 552 | result_index += cwd.len; |
| 553 | } | 553 | } |
| 554 | %defer allocator.free(result); | 554 | errdefer allocator.free(result); |
| 555 | 555 | ||
| 556 | for (paths[first_index..]) |p, i| { | 556 | for (paths[first_index..]) |p, i| { |
| 557 | var it = mem.split(p, "/"); | 557 | var it = mem.split(p, "/"); |
| ... | @@ -943,7 +943,7 @@ pub fn relativeWindows(allocator: &Allocator, from: []const u8, to: []const u8) | ... | @@ -943,7 +943,7 @@ pub fn relativeWindows(allocator: &Allocator, from: []const u8, to: []const u8) |
| 943 | } | 943 | } |
| 944 | const up_index_end = up_count * "..\\".len; | 944 | const up_index_end = up_count * "..\\".len; |
| 945 | const result = try allocator.alloc(u8, up_index_end + to_rest.len); | 945 | const result = try allocator.alloc(u8, up_index_end + to_rest.len); |
| 946 | %defer allocator.free(result); | 946 | errdefer allocator.free(result); |
| 947 | 947 | ||
| 948 | var result_index: usize = 0; | 948 | var result_index: usize = 0; |
| 949 | while (result_index < up_index_end) { | 949 | while (result_index < up_index_end) { |
| ... | @@ -993,7 +993,7 @@ pub fn relativePosix(allocator: &Allocator, from: []const u8, to: []const u8) -> | ... | @@ -993,7 +993,7 @@ pub fn relativePosix(allocator: &Allocator, from: []const u8, to: []const u8) -> |
| 993 | } | 993 | } |
| 994 | const up_index_end = up_count * "../".len; | 994 | const up_index_end = up_count * "../".len; |
| 995 | const result = try allocator.alloc(u8, up_index_end + to_rest.len); | 995 | const result = try allocator.alloc(u8, up_index_end + to_rest.len); |
| 996 | %defer allocator.free(result); | 996 | errdefer allocator.free(result); |
| 997 | 997 | ||
| 998 | var result_index: usize = 0; | 998 | var result_index: usize = 0; |
| 999 | while (result_index < up_index_end) { | 999 | while (result_index < up_index_end) { |
| ... | @@ -1100,7 +1100,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) -> %[]u8 { | ... | @@ -1100,7 +1100,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) -> %[]u8 { |
| 1100 | } | 1100 | } |
| 1101 | defer os.close(h_file); | 1101 | defer os.close(h_file); |
| 1102 | var buf = try allocator.alloc(u8, 256); | 1102 | var buf = try allocator.alloc(u8, 256); |
| 1103 | %defer allocator.free(buf); | 1103 | errdefer allocator.free(buf); |
| 1104 | while (true) { | 1104 | while (true) { |
| 1105 | const buf_len = math.cast(windows.DWORD, buf.len) catch return error.NameTooLong; | 1105 | const buf_len = math.cast(windows.DWORD, buf.len) catch return error.NameTooLong; |
| 1106 | const result = windows.GetFinalPathNameByHandleA(h_file, buf.ptr, buf_len, windows.VOLUME_NAME_DOS); | 1106 | const result = windows.GetFinalPathNameByHandleA(h_file, buf.ptr, buf_len, windows.VOLUME_NAME_DOS); |
| ... | @@ -1144,7 +1144,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) -> %[]u8 { | ... | @@ -1144,7 +1144,7 @@ pub fn real(allocator: &Allocator, pathname: []const u8) -> %[]u8 { |
| 1144 | defer allocator.free(pathname_buf); | 1144 | defer allocator.free(pathname_buf); |
| 1145 | 1145 | ||
| 1146 | const result_buf = try allocator.alloc(u8, posix.PATH_MAX); | 1146 | const result_buf = try allocator.alloc(u8, posix.PATH_MAX); |
| 1147 | %defer allocator.free(result_buf); | 1147 | errdefer allocator.free(result_buf); |
| 1148 | 1148 | ||
| 1149 | mem.copy(u8, pathname_buf, pathname); | 1149 | mem.copy(u8, pathname_buf, pathname); |
| 1150 | pathname_buf[pathname.len] = 0; | 1150 | pathname_buf[pathname.len] = 0; |
std/os/windows/util.zig+1-1| ... | @@ -133,7 +133,7 @@ pub fn createWindowsEnvBlock(allocator: &mem.Allocator, env_map: &const BufMap) | ... | @@ -133,7 +133,7 @@ pub fn createWindowsEnvBlock(allocator: &mem.Allocator, env_map: &const BufMap) |
| 133 | break :x bytes_needed; | 133 | break :x bytes_needed; |
| 134 | }; | 134 | }; |
| 135 | const result = try allocator.alloc(u8, bytes_needed); | 135 | const result = try allocator.alloc(u8, bytes_needed); |
| 136 | %defer allocator.free(result); | 136 | errdefer allocator.free(result); |
| 137 | 137 | ||
| 138 | var it = env_map.iterator(); | 138 | var it = env_map.iterator(); |
| 139 | var i: usize = 0; | 139 | var i: usize = 0; |
test/cases/defer.zig+1-1| ... | @@ -8,7 +8,7 @@ error FalseNotAllowed; | ... | @@ -8,7 +8,7 @@ error FalseNotAllowed; |
| 8 | fn runSomeErrorDefers(x: bool) -> %bool { | 8 | fn runSomeErrorDefers(x: bool) -> %bool { |
| 9 | index = 0; | 9 | index = 0; |
| 10 | defer {result[index] = 'a'; index += 1;} | 10 | defer {result[index] = 'a'; index += 1;} |
| 11 | %defer {result[index] = 'b'; index += 1;} | 11 | errdefer {result[index] = 'b'; index += 1;} |
| 12 | defer {result[index] = 'c'; index += 1;} | 12 | defer {result[index] = 'c'; index += 1;} |
| 13 | return if (x) x else error.FalseNotAllowed; | 13 | return if (x) x else error.FalseNotAllowed; |
| 14 | } | 14 | } |
test/compare_output.zig+4-4| ... | @@ -392,7 +392,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { | ... | @@ -392,7 +392,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { |
| 392 | \\} | 392 | \\} |
| 393 | , "before\ndefer2\ndefer1\n"); | 393 | , "before\ndefer2\ndefer1\n"); |
| 394 | 394 | ||
| 395 | cases.add("%defer and it fails", | 395 | cases.add("errdefer and it fails", |
| 396 | \\const io = @import("std").io; | 396 | \\const io = @import("std").io; |
| 397 | \\pub fn main() -> %void { | 397 | \\pub fn main() -> %void { |
| 398 | \\ do_test() catch return; | 398 | \\ do_test() catch return; |
| ... | @@ -401,7 +401,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { | ... | @@ -401,7 +401,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { |
| 401 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 401 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); |
| 402 | \\ stdout.print("before\n") catch unreachable; | 402 | \\ stdout.print("before\n") catch unreachable; |
| 403 | \\ defer stdout.print("defer1\n") catch unreachable; | 403 | \\ defer stdout.print("defer1\n") catch unreachable; |
| 404 | \\ %defer stdout.print("deferErr\n") catch unreachable; | 404 | \\ errdefer stdout.print("deferErr\n") catch unreachable; |
| 405 | \\ try its_gonna_fail(); | 405 | \\ try its_gonna_fail(); |
| 406 | \\ defer stdout.print("defer3\n") catch unreachable; | 406 | \\ defer stdout.print("defer3\n") catch unreachable; |
| 407 | \\ stdout.print("after\n") catch unreachable; | 407 | \\ stdout.print("after\n") catch unreachable; |
| ... | @@ -412,7 +412,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { | ... | @@ -412,7 +412,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { |
| 412 | \\} | 412 | \\} |
| 413 | , "before\ndeferErr\ndefer1\n"); | 413 | , "before\ndeferErr\ndefer1\n"); |
| 414 | 414 | ||
| 415 | cases.add("%defer and it passes", | 415 | cases.add("errdefer and it passes", |
| 416 | \\const io = @import("std").io; | 416 | \\const io = @import("std").io; |
| 417 | \\pub fn main() -> %void { | 417 | \\pub fn main() -> %void { |
| 418 | \\ do_test() catch return; | 418 | \\ do_test() catch return; |
| ... | @@ -421,7 +421,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { | ... | @@ -421,7 +421,7 @@ pub fn addCases(cases: &tests.CompareOutputContext) { |
| 421 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); | 421 | \\ const stdout = &(io.FileOutStream.init(&(io.getStdOut() catch unreachable)).stream); |
| 422 | \\ stdout.print("before\n") catch unreachable; | 422 | \\ stdout.print("before\n") catch unreachable; |
| 423 | \\ defer stdout.print("defer1\n") catch unreachable; | 423 | \\ defer stdout.print("defer1\n") catch unreachable; |
| 424 | \\ %defer stdout.print("deferErr\n") catch unreachable; | 424 | \\ errdefer stdout.print("deferErr\n") catch unreachable; |
| 425 | \\ try its_gonna_pass(); | 425 | \\ try its_gonna_pass(); |
| 426 | \\ defer stdout.print("defer3\n") catch unreachable; | 426 | \\ defer stdout.print("defer3\n") catch unreachable; |
| 427 | \\ stdout.print("after\n") catch unreachable; | 427 | \\ stdout.print("after\n") catch unreachable; |