mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 21:40:32 +00:00
Merge pull request #8941 from timotheecour/pr_fix_8928
fix #8928 regression
This commit is contained in:
@@ -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
|
||||
|
||||
19
tests/assert/tfailedassert_stacktrace.nim
Normal file
19
tests/assert/tfailedassert_stacktrace.nim
Normal 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
|
||||
Reference in New Issue
Block a user