Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defer doesnt work with block, break and await #15243

Closed
gabbhack opened this issue Aug 29, 2020 · 1 comment
Closed

defer doesnt work with block, break and await #15243

gabbhack opened this issue Aug 29, 2020 · 1 comment

Comments

@gabbhack
Copy link

Example

import asyncdispatch

proc foo() {.async.} =
  echo "foo"

proc main() {.async.} =
  block:
    defer: await foo()
    break

waitFor main()

Current Output

Expected Output

foo
$ nim -v
Nim Compiler Version 1.2.6 [Windows: amd64]
Compiled at 2020-07-29
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: bf320ed172f74f60fd274338e82bdc9ce3520dd9
active boot switches: -d:release
@Araq
Copy link
Member

Araq commented Sep 21, 2020

Other example program:

import asyncdispatch

proc f() {.async.} =
  while true:
    try:
      await sleepAsync(400)
      break
    finally:
      echo "finally handler"
      inc j

when isMainModule:
  waitFor f()

Araq added a commit that referenced this issue Sep 23, 2020
yglukhov added a commit to yglukhov/Nim that referenced this issue Sep 29, 2020
Araq added a commit that referenced this issue Oct 2, 2020
@Araq Araq closed this as completed in aa1d7fe Oct 2, 2020
narimiran pushed a commit that referenced this issue Oct 6, 2020
* fixes #15243 [backport:1.2]

(cherry picked from commit aa1d7fe)
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants