nim-chronos
nim-chronos copied to clipboard
async transformation doesn't handle implicit return
proc works(): Future[int] {.async.} =
return 53
proc works2(): Future[int] {.async.} =
result = 53
proc broken(): Future[int] {.async.} =
53 # Error: expression '53' is of type 'int literal(53)' and has to be discarded
1357045cfa67dc9ca8299b36abab627a1de25511
This is very old known issue.
Because async
macro is working with untyped
arguments its impossible to fix it properly.
For example, if we are going to replace all unattended values with result = <unattended value>
we can go to this problem:
proc empty() {.async.} =
discard
proc notBrokenAnymore(): Future[int] {.async.} =
await works()
proc notBrokenAnymore(): Future[int] {.async.} =
53
proc nowBecomeBroken(): Future[int] {.async.} =
await empty()
Because i can't check type of empty()
i can't make transformation properly.
Fixed in https://github.com/status-im/nim-chronos/pull/401