mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 20:47:53 +00:00
fixes #22469; generates `nimTestErrorFlag` for top level statements
(cherry picked from commit 09d0fda7fd)
This commit is contained in:
@@ -1890,13 +1890,13 @@ proc genInitCode(m: BModule) =
|
||||
if beforeRetNeeded in m.initProc.flags:
|
||||
prc.add("\tBeforeRet_: ;\n")
|
||||
|
||||
if sfMainModule in m.module.flags and m.config.exc == excGoto:
|
||||
if m.config.exc == excGoto:
|
||||
if getCompilerProc(m.g.graph, "nimTestErrorFlag") != nil:
|
||||
m.appcg(prc, "\t#nimTestErrorFlag();$n", [])
|
||||
|
||||
if optStackTrace in m.initProc.options and preventStackTrace notin m.flags:
|
||||
prc.add(deinitFrame(m.initProc))
|
||||
elif sfMainModule in m.module.flags and m.config.exc == excGoto:
|
||||
elif m.config.exc == excGoto:
|
||||
if getCompilerProc(m.g.graph, "nimTestErrorFlag") != nil:
|
||||
m.appcg(prc, "\t#nimTestErrorFlag();$n", [])
|
||||
|
||||
|
||||
4
tests/exception/m22469.nim
Normal file
4
tests/exception/m22469.nim
Normal file
@@ -0,0 +1,4 @@
|
||||
# ModuleB
|
||||
echo "First top-level statement of ModuleB"
|
||||
echo high(int) + 1
|
||||
echo "ModuleB last statement"
|
||||
16
tests/exception/t22469.nim
Normal file
16
tests/exception/t22469.nim
Normal file
@@ -0,0 +1,16 @@
|
||||
discard """
|
||||
exitcode: 1
|
||||
output: '''
|
||||
First top-level statement of ModuleB
|
||||
m22469.nim(3) m22469
|
||||
fatal.nim(53) sysFatal
|
||||
Error: unhandled exception: over- or underflow [OverflowDefect]
|
||||
'''
|
||||
"""
|
||||
|
||||
# bug #22469
|
||||
|
||||
# ModuleA
|
||||
import m22469
|
||||
echo "ModuleA about to have exception"
|
||||
echo high(int) + 1
|
||||
Reference in New Issue
Block a user