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
parent 3516f57e17
commit 2abc936d51
8 changed files with 78 additions and 12 deletions

View File

@@ -91,10 +91,6 @@ template disableVm*(body) =
when nimvm: discard
else: body
template typeOrVoid[T](a: T): type =
# FACTOR with asyncjs.typeOrVoid
T
macro assertAll*(body) =
## works in VM, unlike `check`, `require`
runnableExamples:
@@ -106,6 +102,9 @@ macro assertAll*(body) =
result = newStmtList()
for a in body:
result.add genAst(a) do:
# better than: `when not compiles(typeof(a)):`
when typeOrVoid(a) is void: a
# D20210421T014713:here
# xxx pending https://github.com/nim-lang/Nim/issues/12030,
# `typeof` should introduce its own scope, so that this
# is sufficient: `typeof(a)` instead of `typeof(block: a)`
when typeof(block: a) is void: a
else: doAssert a