mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-05 21:44:46 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user