typeof(voidStmt) now works (#17807)
* `typeof(voidStmt)` now works * remove typeOrVoid * add condsyms, and reference cligen https://github.com/c-blake/cligen/pull/193 * fixup * changelog [skip ci] * fixup
This commit is contained in:
parent
3516f57e17
commit
2abc936d51
8 changed files with 78 additions and 12 deletions
|
|
@ -158,10 +158,6 @@ proc newPromise*(handler: proc(resolve: proc())): Future[void] {.importjs: "(new
|
|||
## A helper for wrapping callback-based functions
|
||||
## into promises and async procedures.
|
||||
|
||||
template typeOrVoid[T](a: T): type =
|
||||
# xxx this is useful, make it public in std/typetraits in future work
|
||||
T
|
||||
|
||||
template maybeFuture(T): untyped =
|
||||
# avoids `Future[Future[T]]`
|
||||
when T is Future: T
|
||||
|
|
@ -221,7 +217,8 @@ when defined(nimExperimentalAsyncjsThen):
|
|||
assert witness == 3
|
||||
|
||||
template impl(call): untyped =
|
||||
when typeOrVoid(call) is void:
|
||||
# see D20210421T014713
|
||||
when typeof(block: call) is void:
|
||||
var ret: Future[void]
|
||||
else:
|
||||
var ret = default(maybeFuture(typeof(call)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue