Merge pull request #8941 from timotheecour/pr_fix_8928

fix #8928 regression
This commit is contained in:
Andreas Rumpf
2018-09-12 10:28:57 +02:00
committed by GitHub
2 changed files with 24 additions and 2 deletions

View File

@@ -3784,8 +3784,11 @@ template assertImpl(cond: bool, msg = "", enabled: static[bool]) =
bind instantiationInfo
mixin failedAssertImpl
when enabled:
if not cond:
failedAssertImpl(loc & " `" & astToStr(cond) & "` " & msg)
# for stacktrace; fixes #8928 ; Note: `fullPaths = true` is correct
# here, regardless of --excessiveStackTrace
{.line: instantiationInfo(fullPaths = true).}:
if not cond:
failedAssertImpl(loc & " `" & astToStr(cond) & "` " & msg)
template assert*(cond: bool, msg = "") =
## Raises ``AssertionError`` with `msg` if `cond` is false. Note

View File

@@ -0,0 +1,19 @@
discard """
output: '''
tfailedassert_stacktrace.nim(16) tfailedassert_stacktrace
tfailedassert_stacktrace.nim(15) foo
system.nim(3777) failedAssertImpl
system.nim(3770) raiseAssert
system.nim(2817) sysFatal
'''
"""
try:
proc foo() =
assert(false)
foo()
except AssertionError:
let e = getCurrentException()
echo e.getStackTrace