Merge pull request #6944 from alehander42/fix-discardable

Make asyncjs Future[void] play nicely with last line discardable calls & forward declaration
This commit is contained in:
Dominik Picheta 2017-12-21 12:25:29 +00:00 • committed by GitHub
commit 8c0e73479e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 12 deletions

View file

@ -1,8 +1,8 @@
discard """
disabled: true
output: '''
0
x
e
'''
"""
@ -10,16 +10,22 @@ import asyncjs
# demonstrate forward definition
# for js
proc y(e: int): Future[string]
proc y(e: int): Future[string] {.async.}
proc x(e: int) {.async.} =
proc e: int {.discardable.} =
echo "e"
return 2
proc x(e: int): Future[void] {.async.} =
var s = await y(e)
echo s
e()
proc y(e: int): Future[string] {.async.} =
echo 0
return "x"
if e > 0:
return await y(0)
else:
return "x"
discard x(2)