fixes #17033 [backport:1.4] (#17061)

* fixes #17033 [backport:1.4]

* make test robust against stdlib gensym things

* cleanup assertions.nim to make topt_no_cursor easier to get right
This commit is contained in:
Andreas Rumpf 2021-02-17 11:00:03 +01:00 • committed by GitHub
commit f32ffb6ed8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 105 additions and 9 deletions

View file

@ -86,13 +86,11 @@ template assert*(cond: untyped, msg = "") =
##
## No code will be generated for `assert` when passing `-d:danger` (implied by `--assertions:off`).
## See `command line switches <nimc.html#compiler-usage-commandminusline-switches>`_.
const expr = astToStr(cond)
assertImpl(cond, msg, expr, compileOption("assertions"))
assertImpl(cond, msg, astToStr(cond), compileOption("assertions"))
template doAssert*(cond: untyped, msg = "") =
## Similar to `assert <#assert.t,untyped,string>`_ but is always turned on regardless of `--assertions`.
const expr = astToStr(cond)
assertImpl(cond, msg, expr, true)
assertImpl(cond, msg, astToStr(cond), true)
template onFailedAssert*(msg, code: untyped): untyped {.dirty.} =
## Sets an assertion failure handler that will intercept any assert