Skip to content

Instantly share code, notes, and snippets.

@RedBeard0531
Created January 10, 2018 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedBeard0531/257097035edf06205b13c2e89c376ab1 to your computer and use it in GitHub Desktop.
Save RedBeard0531/257097035edf06205b13c2e89c376ab1 to your computer and use it in GitHub Desktop.
# nim check -d=nimDumpAsync input.nim
proc foo(): Future[void] =
var retFuture259001 = newFuture[void]("foo")
iterator fooIter259002(): FutureBase {.closure.} =
echo "before await"
var future259003 = newFuture[void]()
yield future259003
if future259003.failed:
setCurrentException(future259003.error)
if future259003.error of Exception:
echo "Exception"
elif true:
echo "except"
elif true:
echo "finally"
elif true:
raise future259003.error
setCurrentException(nil)
else:
try:
future259003.read
echo "after await"
except Exception:
echo "Exception"
except:
echo "except"
finally:
echo "finally"
complete(retFuture259001)
var nameIterVar259006 = fooIter259002
proc foo_continue259004() {.closure.} =
try:
if notnameIterVar259006.finished:
var next259008 = nameIterVar259006()
if next259008 ==
nil:
if notretFuture259001.finished:
let msg259010 = "Async procedure ($1) yielded `nil`, are you await\'ing a " &
"`nil` Future?"
raise newException(AssertionError, msg259010 % "foo")
else:
{.gcsafe.}:
{.push, hint[ConvFromXtoItselfNotNeeded]: off.}
next259008.callback = (proc () {.closure, gcsafe.})(foo_continue259004)
{.pop.}
except:
if retFuture259001.finished:
raise
else:
retFuture259001.fail(getCurrentException())
foo_continue259004()
return retFuture259001
import asyncdispatch
proc foo(): Future[void] {.async.} =
try:
echo "before await"
await newFuture[void]()
echo "after await"
except Exception:
echo "Exception"
except:
echo "except"
finally:
echo "finally"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment