mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-18 02:27:10 +00:00
-d:nimDebug: calls doAssert false instead of quit (#17739)
This commit is contained in:
@@ -2387,13 +2387,13 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) =
|
||||
localError(p.config, e.info, strutils.`%`(errXMustBeCompileTime, e[0].sym.name.s))
|
||||
of mSpawn:
|
||||
when defined(leanCompiler):
|
||||
quit "compiler built without support for the 'spawn' statement"
|
||||
p.config.quitOrRaise "compiler built without support for the 'spawn' statement"
|
||||
else:
|
||||
let n = spawn.wrapProcForSpawn(p.module.g.graph, p.module.idgen, p.module.module, e, e.typ, nil, nil)
|
||||
expr(p, n, d)
|
||||
of mParallel:
|
||||
when defined(leanCompiler):
|
||||
quit "compiler built without support for the 'parallel' statement"
|
||||
p.config.quitOrRaise "compiler built without support for the 'parallel' statement"
|
||||
else:
|
||||
let n = semparallel.liftParallel(p.module.g.graph, p.module.idgen, p.module.module, e)
|
||||
expr(p, n, d)
|
||||
|
||||
@@ -498,7 +498,7 @@ proc runAllExamples(d: PDoc) =
|
||||
"docCmd", group.docCmd,
|
||||
]
|
||||
if os.execShellCmd(cmd) != 0:
|
||||
quit "[runnableExamples] failed: generated file: '$1' group: '$2' cmd: $3" % [outp.string, group[].prettyString, cmd]
|
||||
d.conf.quitOrRaise "[runnableExamples] failed: generated file: '$1' group: '$2' cmd: $3" % [outp.string, group[].prettyString, cmd]
|
||||
else:
|
||||
# keep generated source file `outp` to allow inspection.
|
||||
rawMessage(d.conf, hintSuccess, ["runnableExamples: " & outp.string])
|
||||
|
||||
@@ -1132,7 +1132,7 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
|
||||
|
||||
except:
|
||||
let e = getCurrentException()
|
||||
quit "\ncaught exception:\n" & e.msg & "\nstacktrace:\n" & e.getStackTrace() &
|
||||
conf.quitOrRaise "\ncaught exception:\n" & e.msg & "\nstacktrace:\n" & e.getStackTrace() &
|
||||
"error evaluating JSON file: " & jsonFile.string
|
||||
|
||||
proc genMappingFiles(conf: ConfigRef; list: CfileList): Rope =
|
||||
|
||||
@@ -1149,8 +1149,7 @@ proc rodViewer*(rodfile: AbsoluteFile; config: ConfigRef, cache: IdentCache) =
|
||||
var m: PackedModule
|
||||
let err = loadRodFile(rodfile, m, config, ignoreConfig=true)
|
||||
if err != ok:
|
||||
echo "Error: could not load: ", rodfile.string, " reason: ", err
|
||||
quit 1
|
||||
config.quitOrRaise "Error: could not load: " & $rodfile.string & " reason: " & $err
|
||||
|
||||
when true:
|
||||
echo "exports:"
|
||||
|
||||
@@ -229,7 +229,7 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||
|
||||
template docLikeCmd(body) =
|
||||
when defined(leanCompiler):
|
||||
quit "compiler wasn't built with documentation generator"
|
||||
conf.quitOrRaise "compiler wasn't built with documentation generator"
|
||||
else:
|
||||
wantMainModule(conf)
|
||||
loadConfigs(DocConfig, cache, conf, graph.idgen)
|
||||
@@ -278,7 +278,7 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||
conf.setNoteDefaults(warn, true)
|
||||
conf.setNoteDefaults(warnRedefinitionOfLabel, false) # similar to issue #13218
|
||||
when defined(leanCompiler):
|
||||
quit "compiler wasn't built with documentation generator"
|
||||
conf.quitOrRaise "compiler wasn't built with documentation generator"
|
||||
else:
|
||||
loadConfigs(DocConfig, cache, conf, graph.idgen)
|
||||
commandRst2Html(cache, conf)
|
||||
@@ -288,7 +288,7 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||
warnFieldXNotSupported, warnRstStyle]:
|
||||
conf.setNoteDefaults(warn, true)
|
||||
when defined(leanCompiler):
|
||||
quit "compiler wasn't built with documentation generator"
|
||||
conf.quitOrRaise "compiler wasn't built with documentation generator"
|
||||
else:
|
||||
loadConfigs(DocTexConfig, cache, conf, graph.idgen)
|
||||
commandRst2TeX(cache, conf)
|
||||
|
||||
@@ -398,7 +398,8 @@ proc log*(s: string) =
|
||||
close(f)
|
||||
|
||||
proc quit(conf: ConfigRef; msg: TMsgKind) {.gcsafe.} =
|
||||
if defined(debug) or msg == errInternal or conf.hasHint(hintStackTrace):
|
||||
if conf.isDefined("nimDebug"): quitOrRaise(conf, $msg)
|
||||
elif defined(debug) or msg == errInternal or conf.hasHint(hintStackTrace):
|
||||
{.gcsafe.}:
|
||||
if stackTraceAvailable() and isNil(conf.writelnHook):
|
||||
writeStackTrace()
|
||||
|
||||
@@ -576,6 +576,13 @@ proc isDefined*(conf: ConfigRef; symbol: string): bool =
|
||||
osDragonfly, osMacosx}
|
||||
else: discard
|
||||
|
||||
template quitOrRaise*(conf: ConfigRef, msg = "") =
|
||||
# xxx in future work, consider whether to also intercept `msgQuit` calls
|
||||
if conf.isDefined("nimDebug"):
|
||||
doAssert false, msg
|
||||
else:
|
||||
quit(msg) # quits with QuitFailure
|
||||
|
||||
proc importantComments*(conf: ConfigRef): bool {.inline.} = conf.cmd in cmdDocLike + {cmdIdeTools}
|
||||
proc usesWriteBarrier*(conf: ConfigRef): bool {.inline.} = conf.selectedGC >= gcRefc
|
||||
|
||||
@@ -732,8 +739,7 @@ proc completeGeneratedFilePath*(conf: ConfigRef; f: AbsoluteFile,
|
||||
try:
|
||||
createDir(subdir.string)
|
||||
except OSError:
|
||||
writeLine(stdout, "cannot create directory: " & subdir.string)
|
||||
quit(1)
|
||||
conf.quitOrRaise "cannot create directory: " & subdir.string
|
||||
result = subdir / RelativeFile f.string.splitPath.tail
|
||||
#echo "completeGeneratedFilePath(", f, ") = ", result
|
||||
|
||||
|
||||
@@ -1011,7 +1011,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
||||
when declared(deallocatedRefId):
|
||||
let corrupt = deallocatedRefId(cast[pointer](f))
|
||||
if corrupt != 0:
|
||||
quit "it's corrupt " & $corrupt
|
||||
c.c.config.quitOrRaise "it's corrupt " & $corrupt
|
||||
|
||||
if f.kind == tyUntyped:
|
||||
if aOrig != nil: put(c, f, aOrig)
|
||||
|
||||
@@ -50,7 +50,7 @@ proc parsePipe(filename: AbsoluteFile, inputStream: PLLStream; cache: IdentCache
|
||||
if i+1 < line.len and line[i] == '#' and line[i+1] == '?':
|
||||
when defined(nimpretty):
|
||||
# XXX this is a bit hacky, but oh well...
|
||||
quit "can't nimpretty a source code filter"
|
||||
config.quitOrRaise "can't nimpretty a source code filter: " & $filename
|
||||
else:
|
||||
inc(i, 2)
|
||||
while i < line.len and line[i] in Whitespace: inc(i)
|
||||
|
||||
Reference in New Issue
Block a user