summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--doc/manual/stmts.txt18
1 files changed, 18 insertions, 0 deletions
diff --git a/doc/manual/stmts.txt b/doc/manual/stmts.txt
index 062c08d7c..a833d7b7d 100644
--- a/doc/manual/stmts.txt
+++ b/doc/manual/stmts.txt
@@ -60,6 +60,24 @@ An empty ``discard`` statement is often used as a null statement:
     else: discard
 
 
+Void context
+------------
+
+In a list of statements every expression except the last one needs to have the
+type ``void``. In addition to this rule an assignment to the builtin ``result``
+symbol also triggers a ``void`` context:
+
+.. code-block:: nim
+  proc invalid*(): string =
+    result = "foo"
+    "invalid"  # Error: value of type 'string' has to be discarded
+
+.. code-block:: nim
+  proc valid*(): string =
+    let x = 317
+    "valid"
+
+
 Var statement
 -------------