Merge branch 'cpp_reraise_fix' into yield-in-try-fix
This commit is contained in:
commit
d31404ac27
2 changed files with 33 additions and 6 deletions
|
|
@ -342,12 +342,15 @@ proc raiseExceptionAux(e: ref Exception) =
|
||||||
if globalRaiseHook != nil:
|
if globalRaiseHook != nil:
|
||||||
if not globalRaiseHook(e): return
|
if not globalRaiseHook(e): return
|
||||||
when defined(cpp) and not defined(noCppExceptions):
|
when defined(cpp) and not defined(noCppExceptions):
|
||||||
pushCurrentException(e)
|
if e == currException:
|
||||||
raiseCounter.inc
|
{.emit: "throw;".}
|
||||||
if raiseCounter == 0:
|
else:
|
||||||
raiseCounter.inc # skip zero at overflow
|
pushCurrentException(e)
|
||||||
e.raiseId = raiseCounter
|
raiseCounter.inc
|
||||||
{.emit: "`e`->raise();".}
|
if raiseCounter == 0:
|
||||||
|
raiseCounter.inc # skip zero at overflow
|
||||||
|
e.raiseId = raiseCounter
|
||||||
|
{.emit: "`e`->raise();".}
|
||||||
elif defined(nimQuirky):
|
elif defined(nimQuirky):
|
||||||
pushCurrentException(e)
|
pushCurrentException(e)
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@ bar
|
||||||
Need odd and >= 3 digits##
|
Need odd and >= 3 digits##
|
||||||
baz
|
baz
|
||||||
caught
|
caught
|
||||||
|
--------
|
||||||
|
Triggered raises2
|
||||||
|
Raising ValueError
|
||||||
'''
|
'''
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -45,3 +48,24 @@ try:
|
||||||
finally:
|
finally:
|
||||||
for foobar in strs:
|
for foobar in strs:
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
|
||||||
|
# issue #11118
|
||||||
|
echo "--------"
|
||||||
|
proc raises() =
|
||||||
|
raise newException(ValueError, "Raising ValueError")
|
||||||
|
|
||||||
|
proc raises2() =
|
||||||
|
try:
|
||||||
|
raises()
|
||||||
|
except ValueError as e:
|
||||||
|
echo "Triggered raises2"
|
||||||
|
raise e
|
||||||
|
|
||||||
|
try:
|
||||||
|
raises2()
|
||||||
|
except:
|
||||||
|
echo getCurrentExceptionMsg()
|
||||||
|
discard
|
||||||
|
|
||||||
|
doAssert: getCurrentException() == nil
|
||||||
Loading…
Add table
Add a link
Reference in a new issue