Skip to content

Commit 3ce6de8

Browse files
committed
revert langref section "common errdefer slip ups"
This does not belong in the language reference. reverts 91a88a7
1 parent 11bf2d9 commit 3ce6de8

5 files changed

+0
-178
lines changed

doc/langref.html.in

-26
Original file line numberDiff line numberDiff line change
@@ -3052,32 +3052,6 @@ fn createFoo(param: i32) !Foo {
30523052
The {#syntax#}errdefer{#endsyntax#} statement can optionally capture the error:
30533053
</p>
30543054
{#code|test_errdefer_capture.zig#}
3055-
{#header_close#}
3056-
{#header_open|Common errdefer Slip-Ups#}
3057-
<p>
3058-
It should be noted that {#syntax#}errdefer{#endsyntax#} statements only last until the end of the block
3059-
they are written in, and therefore are not run if an error is returned outside of that block:
3060-
</p>
3061-
{#code|test_errdefer_slip_ups.zig#}
3062-
3063-
<p>
3064-
To ensure that {#syntax#}deallocateFoo{#endsyntax#} is properly called
3065-
when returning an error, you must add an {#syntax#}errdefer{#endsyntax#} outside of the block:
3066-
</p>
3067-
{#code|test_errdefer_block.zig#}
3068-
3069-
<p>
3070-
The fact that errdefers only last for the block they are declared in is
3071-
especially important when using loops:
3072-
</p>
3073-
{#code|test_errdefer_loop_leak.zig#}
3074-
3075-
<p>
3076-
Special care must be taken with code that allocates in a loop
3077-
to make sure that no memory is leaked when returning an error:
3078-
</p>
3079-
{#code|test_errdefer_loop.zig#}
3080-
30813055
{#header_close#}
30823056
<p>
30833057
A couple of other tidbits about error handling:

doc/langref/test_errdefer_block.zig

-42
This file was deleted.

doc/langref/test_errdefer_loop.zig

-36
This file was deleted.

doc/langref/test_errdefer_loop_leak.zig

-32
This file was deleted.

doc/langref/test_errdefer_slip_ups.zig

-42
This file was deleted.

0 commit comments

Comments
 (0)