mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-05 11:24:08 +00:00
In CPS we would consume an exception in the except branch by stashing it into a local then remove the exception from Nim environment so as not to leak it to other code that would be running before the continuation continues However since popCurrentException() assumes that the exception always exist, removing the exception from an except branch will cause a SIGSEGV to happen. This commit fixes that.
16 lines
348 B
Nim
16 lines
348 B
Nim
discard """
|
|
targets: "c cpp js"
|
|
"""
|
|
|
|
let ex = newException(CatchableError, "test")
|
|
setCurrentException(ex)
|
|
doAssert getCurrentException().msg == ex.msg
|
|
doAssert getCurrentExceptionMsg() == ex.msg
|
|
setCurrentException(nil)
|
|
|
|
try:
|
|
raise newException(CatchableError, "test2")
|
|
except:
|
|
setCurrentException(nil)
|
|
doAssert getCurrentException() == nil
|