summary refs log tree commit diff stats
path: root/tests/discard
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2014-03-05 08:30:05 +0100
committerAraq <rumpf_a@web.de>2014-03-05 08:30:05 +0100
commit4f946cb44e4fe60451b8ce4d15868ef0bce6949a (patch)
tree2111a867a40015e185b8439ac19b4a22d7b0ee7a /tests/discard
parent94e444c90fa1c8848b398bc163e7f78d7f0b3080 (diff)
downloadNim-4f946cb44e4fe60451b8ce4d15868ef0bce6949a.tar.gz
fixes #942
Diffstat (limited to 'tests/discard')
-rw-r--r--tests/discard/tdiscardable.nim16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/discard/tdiscardable.nim b/tests/discard/tdiscardable.nim
index c0551ba2f..a806ccdce 100644
--- a/tests/discard/tdiscardable.nim
+++ b/tests/discard/tdiscardable.nim
@@ -11,3 +11,19 @@ proc q[T](x, y: T): T {.discardable.} =
 p(8, 2)
 q[float](0.8, 0.2)
 
+# bug #942
+
+template maybeMod(x: Tinteger, module:Natural):expr =
+  if module > 0: x mod module
+  else: x
+
+proc foo(b: int):int =
+  var x = 1
+  result = x.maybeMod(b) # Works fine
+
+proc bar(b: int):int =
+  result = 1
+  result = result.maybeMod(b) # Error: value returned by statement has to be discarded
+
+echo foo(0)
+echo bar(0)