Fix infinite recursion when await is in except body.
This commit is contained in:
parent
edc4940c26
commit
3751019823
3 changed files with 31 additions and 3 deletions
|
|
@ -1273,7 +1273,7 @@ proc processBody(node, retFutureSym: NimNode,
|
||||||
else: discard
|
else: discard
|
||||||
|
|
||||||
for i in 0 .. <result.len:
|
for i in 0 .. <result.len:
|
||||||
result[i] = processBody(result[i], retFutureSym, subTypeIsVoid, tryStmt)
|
result[i] = processBody(result[i], retFutureSym, subTypeIsVoid, nil)
|
||||||
|
|
||||||
proc getName(node: NimNode): string {.compileTime.} =
|
proc getName(node: NimNode): string {.compileTime.} =
|
||||||
case node.kind
|
case node.kind
|
||||||
|
|
@ -1378,8 +1378,8 @@ macro async*(prc: stmt): stmt {.immediate.} =
|
||||||
result[6] = outerProcBody
|
result[6] = outerProcBody
|
||||||
|
|
||||||
#echo(treeRepr(result))
|
#echo(treeRepr(result))
|
||||||
if prc[0].getName == "test3":
|
#if prc[0].getName == "test":
|
||||||
echo(toStrLit(result))
|
# echo(toStrLit(result))
|
||||||
|
|
||||||
proc recvLine*(socket: TAsyncFD): Future[string] {.async.} =
|
proc recvLine*(socket: TAsyncFD): Future[string] {.async.} =
|
||||||
## Reads a line of data from ``socket``. Returned future will complete once
|
## Reads a line of data from ``socket``. Returned future will complete once
|
||||||
|
|
|
||||||
|
|
@ -82,6 +82,15 @@ proc test3(): Future[int] {.async.} =
|
||||||
result = 2
|
result = 2
|
||||||
return
|
return
|
||||||
|
|
||||||
|
proc test4(): Future[int] {.async.} =
|
||||||
|
try:
|
||||||
|
discard await foo()
|
||||||
|
raise newException(ValueError, "Test4")
|
||||||
|
except OSError:
|
||||||
|
result = 1
|
||||||
|
except:
|
||||||
|
result = 2
|
||||||
|
|
||||||
var x = test()
|
var x = test()
|
||||||
assert x.read
|
assert x.read
|
||||||
|
|
||||||
|
|
@ -90,3 +99,6 @@ assert x.read
|
||||||
|
|
||||||
var y = test3()
|
var y = test3()
|
||||||
assert y.read == 2
|
assert y.read == 2
|
||||||
|
|
||||||
|
y = test4()
|
||||||
|
assert y.read == 2
|
||||||
|
|
|
||||||
16
tests/async/tasynctry2.nim
Normal file
16
tests/async/tasynctry2.nim
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue