summary refs log tree commit diff stats
path: root/tests/async
diff options
context:
space:
mode:
authorDominik Picheta <dominikpicheta@googlemail.com>2015-03-30 00:42:21 +0100
committerDominik Picheta <dominikpicheta@googlemail.com>2015-03-30 00:42:21 +0100
commit3751019823ee78bd67b44cb27bc331913f12ff47 (patch)
tree3c19006142027d70d6f64eb045f6198b9a587d22 /tests/async
parentedc4940c26dc6f90faeccac0d7752446667e9551 (diff)
downloadNim-3751019823ee78bd67b44cb27bc331913f12ff47.tar.gz
Fix infinite recursion when await is in except body.
Diffstat (limited to 'tests/async')
-rw-r--r--tests/async/tasynctry.nim12
-rw-r--r--tests/async/tasynctry2.nim16
2 files changed, 28 insertions, 0 deletions
diff --git a/tests/async/tasynctry.nim b/tests/async/tasynctry.nim
index 99433b9d8..f77198e2e 100644
--- a/tests/async/tasynctry.nim
+++ b/tests/async/tasynctry.nim
@@ -82,6 +82,15 @@ proc test3(): Future[int] {.async.} =
     result = 2
     return
 
+proc test4(): Future[int] {.async.} =
+  try:
+    discard await foo()
+    raise newException(ValueError, "Test4")
+  except OSError:
+    result = 1
+  except:
+    result = 2
+
 var x = test()
 assert x.read
 
@@ -90,3 +99,6 @@ assert x.read
 
 var y = test3()
 assert y.read == 2
+
+y = test4()
+assert y.read == 2
diff --git a/tests/async/tasynctry2.nim b/tests/async/tasynctry2.nim
new file mode 100644
index 000000000..444a058be
--- /dev/null
+++ b/tests/async/tasynctry2.nim
@@ -0,0 +1,16 @@
+discard """
+  file: "tasynctry2.nim"
+  errormsg: "\'yield\' cannot be used within \'try\' in a non-inlined iterator"
+  line: 15
+"""
+import asyncdispatch
+
+proc foo(): Future[bool] {.async.} = discard
+
+proc test5(): Future[int] {.async.} =
+  try:
+    discard await foo()
+    raise newException(ValueError, "Test5")
+  except:
+    discard await foo()
+    result = 0