zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 8328f5ed51aee877dfc616be5d6fdcaa09becdca (tree)
parent f3517a1aa6058e9b09d57e81ecc81f27f086d163
Author: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Date:   Tue, 17 May 2022 18:34:28 +0200

docs: add documentation about return stm in the defer method

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

Diffstat:
Mdoc/langref.html.in | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/doc/langref.html.in b/doc/langref.html.in @@ -4813,6 +4813,19 @@ fn deferErrorExample(is_error: bool) !void { print("encountered an error!\n", .{}); } + // inside a defer method the return statement + // is not allowed. + // The following lines produce the following + // error if uncomment + // ``` + // defer.zig:73:9: error: cannot return from defer expression + // return error.DeferError; + // ``` + // + //defer { + // return error.DeferError; + //} + if (is_error) { return error.DeferError; }