From bc725eaa131b621bec7a8af084f631c1d31c0bf8 Mon Sep 17 00:00:00 2001 From: Araq Date: Thu, 10 Sep 2015 13:18:11 +0200 Subject: documented void context --- doc/manual/stmts.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'doc/manual/stmts.txt') 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 ------------- -- cgit 1.4.1-2-gfad0