ref #20694; quit value gets saturated to ranges (#20753)

* quit value gets saturated to ranges

* add documentation

* minimal changes

* refactor

* small fix

* add documentation

* fixes

* Update lib/system.nim

Co-authored-by: Juan Carlos <juancarlospaco@gmail.com>

Co-authored-by: Juan Carlos <juancarlospaco@gmail.com>
This commit is contained in:
ringabout 2022-11-05 17:58:57 +08:00 • committed by GitHub
commit d5cc2085ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 95 additions and 64 deletions

View file

@ -415,7 +415,7 @@ proc nimLeaveFinally() {.compilerRtl.} =
c_longjmp(excHandler.context, 1)
else:
reportUnhandledError(currException)
quit(1)
rawQuit(1)
when gotoBasedExceptions:
var nimInErrorMode {.threadvar.}: bool
@ -430,13 +430,13 @@ when gotoBasedExceptions:
if nimInErrorMode and currException != nil:
reportUnhandledError(currException)
currException = nil
quit(1)
rawQuit(1)
proc raiseExceptionAux(e: sink(ref Exception)) {.nodestroy.} =
when defined(nimPanics):
if e of Defect:
reportUnhandledError(e)
quit(1)
rawQuit(1)
if localRaiseHook != nil:
if not localRaiseHook(e): return
@ -458,7 +458,7 @@ proc raiseExceptionAux(e: sink(ref Exception)) {.nodestroy.} =
c_longjmp(excHandler.context, 1)
else:
reportUnhandledError(e)
quit(1)
rawQuit(1)
proc raiseExceptionEx(e: sink(ref Exception), ename, procname, filename: cstring,
line: int) {.compilerRtl, nodestroy.} =
@ -501,7 +501,7 @@ proc threadTrouble() =
if currException != nil: reportUnhandledError(currException)
except:
discard
quit 1
rawQuit 1
proc writeStackTrace() =
when hasSomeStackTrace:
@ -544,7 +544,7 @@ proc callDepthLimitReached() {.noinline.} =
"-d:nimCallDepthLimit=<int> but really try to avoid deep " &
"recursions instead.\n"
showErrorMessage2(msg)
quit(1)
rawQuit(1)
proc nimFrame(s: PFrame) {.compilerRtl, inl, raises: [].} =
if framePtr == nil:
@ -597,7 +597,7 @@ when defined(cpp) and appType != "lib" and not gotoBasedExceptions and
else:
writeToStdErr msg & "\n"
quit 1
rawQuit 1
when not defined(noSignalHandler) and not defined(useNimRtl):
type Sighandler = proc (a: cint) {.noconv, benign.}
@ -651,7 +651,7 @@ when not defined(noSignalHandler) and not defined(useNimRtl):
# also return the correct exit code to the shell.
discard c_raise(sign)
else:
quit(1)
rawQuit(1)
var SIG_IGN {.importc: "SIG_IGN", header: "<signal.h>".}: Sighandler