catchable defects (#13626)

* allow defects to be caught even for --exceptions:goto (WIP)
* implemented the new --panics:on|off switch; refs https://github.com/nim-lang/RFCs/issues/180
* new implementation for integer overflow checking
* produce a warning if a user-defined exception type inherits from Exception directly
* applied Timothee's suggestions; improved the documentation and replace the term 'checked runtime check' by 'panic'
* fixes #13627
* don't inherit from Exception directly
This commit is contained in:
Andreas Rumpf 2020-03-12 23:44:33 +01:00 • committed by GitHub
commit a6682de004
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 441 additions and 142 deletions

View file

@ -90,6 +90,7 @@ type # please make sure we have under 32 options
optNimV019
optBenchmarkVM # Enables cpuTime() in the VM
optProduceAsm # produce assembler code
optPanics # turn panics (sysFatal) into a process termination
TGlobalOptions* = set[TGlobalOption]
@ -509,15 +510,17 @@ proc getOutFile*(conf: ConfigRef; filename: RelativeFile, ext: string): Absolute
proc absOutFile*(conf: ConfigRef): AbsoluteFile =
result = conf.outDir / conf.outFile
if dirExists(result.string):
result.string.add ".out"
when defined(posix):
if dirExists(result.string):
result.string.add ".out"
proc prepareToWriteOutput*(conf: ConfigRef): AbsoluteFile =
## Create the output directory and returns a full path to the output file
createDir conf.outDir
result = conf.outDir / conf.outFile
if dirExists(result.string):
result.string.add ".out"
when defined(posix):
if dirExists(result.string):
result.string.add ".out"
proc getPrefixDir*(conf: ConfigRef): AbsoluteDir =
## Gets the prefix dir, usually the parent directory where the binary resides.