fixes #21261; always checking nimTestErrorFlag in the main module (#21288)

* fixes #21261; always checking nimTestErrorFlag in the main module

* add a test
This commit is contained in:
ringabout
2023-01-24 22:37:22 +08:00
committed by GitHub
parent 5e7f7109e1
commit d54a7f078d
3 changed files with 13 additions and 0 deletions

View File

@@ -1801,6 +1801,9 @@ proc genInitCode(m: BModule) =
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:
if getCompilerProc(m.g.graph, "nimTestErrorFlag") != nil:
m.appcg(prc, "\t#nimTestErrorFlag();$n", [])
prc.addf("}$N", [])

View File

@@ -0,0 +1 @@
raise (ref Exception)(msg: "something")

View File

@@ -0,0 +1,9 @@
discard """
exitcode: 1
outputsub: '''
m21261.nim(1) m21261
Error: unhandled exception: something [Exception]
'''
"""
import m21261