Skip to content

Commit

Permalink
Revert "make system/fatal importable (#20718)"
Browse files Browse the repository at this point in the history
This reverts commit d735c44.
  • Loading branch information
ringabout committed Nov 3, 2022
1 parent 4503fa5 commit 0a7ef1c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion lib/std/assertions.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

## This module implements assertion handling.

import system/fatal
when not declared(sysFatal):
include "system/fatal"

import std/private/miscdollars
# ---------------------------------------------------------------------------
Expand Down
9 changes: 2 additions & 7 deletions lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1637,13 +1637,8 @@ when not defined(nimscript):
## for debug builds. Since it's usually used for debugging, this
## is proclaimed to have no IO effect!


when defined(nimHasExceptionsQuery):
const gotoBasedExceptions = compileOption("exceptions", "goto")
else:
const gotoBasedExceptions = false

import system/fatal
when not declared(sysFatal):
include "system/fatal"

when not defined(nimscript):
{.push stackTrace: off, profiler: off.}
Expand Down
19 changes: 12 additions & 7 deletions lib/system/fatal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,27 @@

{.push profiler: off.}

when defined(nimHasExceptionsQuery):
const gotoBasedExceptions = compileOption("exceptions", "goto")
else:
const gotoBasedExceptions = false

when hostOS == "standalone":
include "$projectpath/panicoverride"

func sysFatal*(exceptn: typedesc, message: string) {.inline.} =
func sysFatal(exceptn: typedesc, message: string) {.inline.} =
panic(message)

func sysFatal*(exceptn: typedesc, message, arg: string) {.inline.} =
func sysFatal(exceptn: typedesc, message, arg: string) {.inline.} =
rawoutput(message)
panic(arg)

elif (defined(nimQuirky) or defined(nimPanics)) and not defined(nimscript):
import system/ansi_c
import ansi_c

func name(t: typedesc): string {.magic: "TypeTrait".}

func sysFatal*(exceptn: typedesc, message, arg: string) {.inline, noreturn.} =
func sysFatal(exceptn: typedesc, message, arg: string) {.inline, noreturn.} =
when nimvm:
# TODO when doAssertRaises works in CT, add a test for it
raise (ref exceptn)(msg: message & arg)
Expand All @@ -41,14 +46,14 @@ elif (defined(nimQuirky) or defined(nimPanics)) and not defined(nimscript):
cstderr.rawWrite buf
quit 1

func sysFatal*(exceptn: typedesc, message: string) {.inline, noreturn.} =
func sysFatal(exceptn: typedesc, message: string) {.inline, noreturn.} =
sysFatal(exceptn, message, "")

else:
func sysFatal*(exceptn: typedesc, message: string) {.inline, noreturn.} =
func sysFatal(exceptn: typedesc, message: string) {.inline, noreturn.} =
raise (ref exceptn)(msg: message)

func sysFatal*(exceptn: typedesc, message, arg: string) {.inline, noreturn.} =
func sysFatal(exceptn: typedesc, message, arg: string) {.inline, noreturn.} =
raise (ref exceptn)(msg: message & arg)

{.pop.}

0 comments on commit 0a7ef1c

Please sign in to comment.