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:
Timothee Cour 2021-04-23 05:36:38 -07:00 • committed by GitHub
commit 2abc936d51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 78 additions and 12 deletions

View file

@ -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)))