aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2017-12-22 00:50:30 -0500
committerAndrew Kelley <superjoe30@gmail.com>2017-12-22 00:50:30 -0500
commitd917815d8111b98dc237cbe2c723fa63018e02b1 (patch)
treece12771a86b2412ee9692ca73d3ca49abe5da3ce /doc
parent8bc523219c66427951e5339550502871547f2138 (diff)
downloadzig-d917815d8111b98dc237cbe2c723fa63018e02b1.tar.gz
zig-d917815d8111b98dc237cbe2c723fa63018e02b1.zip
explicitly return from blocks
instead of last statement being expression value closes #629
Diffstat (limited to 'doc')
-rw-r--r--doc/docgen.zig2
-rw-r--r--doc/langref.html.in5
2 files changed, 3 insertions, 4 deletions
diff --git a/doc/docgen.zig b/doc/docgen.zig
index bec12d98b7..d481baf4b3 100644
--- a/doc/docgen.zig
+++ b/doc/docgen.zig
@@ -49,7 +49,7 @@ fn gen(in: &io.InStream, out: &io.OutStream) {
if (err == error.EndOfStream) {
return;
}
- std.debug.panic("{}", err)
+ std.debug.panic("{}", err);
};
switch (state) {
State.Start => switch (byte) {
diff --git a/doc/langref.html.in b/doc/langref.html.in
index faba4f8b10..162c8b3e03 100644
--- a/doc/langref.html.in
+++ b/doc/langref.html.in
@@ -3021,14 +3021,13 @@ const assert = @import("std").debug.assert;</code></pre>
<pre><code class="zig">const assert = @import("std").debug.assert;
// Functions are declared like this
-// The last expression in the function can be used as the return value.
fn add(a: i8, b: i8) -&gt; i8 {
if (a == 0) {
// You can still return manually if needed.
return b;
}
- a + b
+ return a + b;
}
// The export specifier makes a function externally visible in the generated
@@ -5847,7 +5846,7 @@ ParamDeclList = "(" list(ParamDecl, ",") ")"
ParamDecl = option("noalias" | "comptime") option(Symbol ":") (TypeExpr | "...")
-Block = option(Symbol ":") "{" many(Statement) option(Expression) "}"
+Block = option(Symbol ":") "{" many(Statement) "}"
Statement = LocalVarDecl ";" | Defer(Block) | Defer(Expression) ";" | BlockExpression(Block) | Expression ";" | ";"