-d:nimDebug: calls doAssert false instead of quit (#17739)
This commit is contained in:
parent
5c5f356347
commit
5c9c1988f6
9 changed files with 20 additions and 14 deletions
|
|
@ -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))
|
localError(p.config, e.info, strutils.`%`(errXMustBeCompileTime, e[0].sym.name.s))
|
||||||
of mSpawn:
|
of mSpawn:
|
||||||
when defined(leanCompiler):
|
when defined(leanCompiler):
|
||||||
quit "compiler built without support for the 'spawn' statement"
|
p.config.quitOrRaise "compiler built without support for the 'spawn' statement"
|
||||||
else:
|
else:
|
||||||
let n = spawn.wrapProcForSpawn(p.module.g.graph, p.module.idgen, p.module.module, e, e.typ, nil, nil)
|
let n = spawn.wrapProcForSpawn(p.module.g.graph, p.module.idgen, p.module.module, e, e.typ, nil, nil)
|
||||||
expr(p, n, d)
|
expr(p, n, d)
|
||||||
of mParallel:
|
of mParallel:
|
||||||
when defined(leanCompiler):
|
when defined(leanCompiler):
|
||||||
quit "compiler built without support for the 'parallel' statement"
|
p.config.quitOrRaise "compiler built without support for the 'parallel' statement"
|
||||||
else:
|
else:
|
||||||
let n = semparallel.liftParallel(p.module.g.graph, p.module.idgen, p.module.module, e)
|
let n = semparallel.liftParallel(p.module.g.graph, p.module.idgen, p.module.module, e)
|
||||||
expr(p, n, d)
|
expr(p, n, d)
|
||||||
|
|
|
||||||
|
|
@ -498,7 +498,7 @@ proc runAllExamples(d: PDoc) =
|
||||||
"docCmd", group.docCmd,
|
"docCmd", group.docCmd,
|
||||||
]
|
]
|
||||||
if os.execShellCmd(cmd) != 0:
|
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:
|
else:
|
||||||
# keep generated source file `outp` to allow inspection.
|
# keep generated source file `outp` to allow inspection.
|
||||||
rawMessage(d.conf, hintSuccess, ["runnableExamples: " & outp.string])
|
rawMessage(d.conf, hintSuccess, ["runnableExamples: " & outp.string])
|
||||||
|
|
|
||||||
|
|
@ -1132,7 +1132,7 @@ proc runJsonBuildInstructions*(conf: ConfigRef; projectfile: AbsoluteFile) =
|
||||||
|
|
||||||
except:
|
except:
|
||||||
let e = getCurrentException()
|
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
|
"error evaluating JSON file: " & jsonFile.string
|
||||||
|
|
||||||
proc genMappingFiles(conf: ConfigRef; list: CfileList): Rope =
|
proc genMappingFiles(conf: ConfigRef; list: CfileList): Rope =
|
||||||
|
|
|
||||||
|
|
@ -1149,8 +1149,7 @@ proc rodViewer*(rodfile: AbsoluteFile; config: ConfigRef, cache: IdentCache) =
|
||||||
var m: PackedModule
|
var m: PackedModule
|
||||||
let err = loadRodFile(rodfile, m, config, ignoreConfig=true)
|
let err = loadRodFile(rodfile, m, config, ignoreConfig=true)
|
||||||
if err != ok:
|
if err != ok:
|
||||||
echo "Error: could not load: ", rodfile.string, " reason: ", err
|
config.quitOrRaise "Error: could not load: " & $rodfile.string & " reason: " & $err
|
||||||
quit 1
|
|
||||||
|
|
||||||
when true:
|
when true:
|
||||||
echo "exports:"
|
echo "exports:"
|
||||||
|
|
|
||||||
|
|
@ -229,7 +229,7 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
|
|
||||||
template docLikeCmd(body) =
|
template docLikeCmd(body) =
|
||||||
when defined(leanCompiler):
|
when defined(leanCompiler):
|
||||||
quit "compiler wasn't built with documentation generator"
|
conf.quitOrRaise "compiler wasn't built with documentation generator"
|
||||||
else:
|
else:
|
||||||
wantMainModule(conf)
|
wantMainModule(conf)
|
||||||
loadConfigs(DocConfig, cache, conf, graph.idgen)
|
loadConfigs(DocConfig, cache, conf, graph.idgen)
|
||||||
|
|
@ -278,7 +278,7 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
conf.setNoteDefaults(warn, true)
|
conf.setNoteDefaults(warn, true)
|
||||||
conf.setNoteDefaults(warnRedefinitionOfLabel, false) # similar to issue #13218
|
conf.setNoteDefaults(warnRedefinitionOfLabel, false) # similar to issue #13218
|
||||||
when defined(leanCompiler):
|
when defined(leanCompiler):
|
||||||
quit "compiler wasn't built with documentation generator"
|
conf.quitOrRaise "compiler wasn't built with documentation generator"
|
||||||
else:
|
else:
|
||||||
loadConfigs(DocConfig, cache, conf, graph.idgen)
|
loadConfigs(DocConfig, cache, conf, graph.idgen)
|
||||||
commandRst2Html(cache, conf)
|
commandRst2Html(cache, conf)
|
||||||
|
|
@ -288,7 +288,7 @@ proc mainCommand*(graph: ModuleGraph) =
|
||||||
warnFieldXNotSupported, warnRstStyle]:
|
warnFieldXNotSupported, warnRstStyle]:
|
||||||
conf.setNoteDefaults(warn, true)
|
conf.setNoteDefaults(warn, true)
|
||||||
when defined(leanCompiler):
|
when defined(leanCompiler):
|
||||||
quit "compiler wasn't built with documentation generator"
|
conf.quitOrRaise "compiler wasn't built with documentation generator"
|
||||||
else:
|
else:
|
||||||
loadConfigs(DocTexConfig, cache, conf, graph.idgen)
|
loadConfigs(DocTexConfig, cache, conf, graph.idgen)
|
||||||
commandRst2TeX(cache, conf)
|
commandRst2TeX(cache, conf)
|
||||||
|
|
|
||||||
|
|
@ -398,7 +398,8 @@ proc log*(s: string) =
|
||||||
close(f)
|
close(f)
|
||||||
|
|
||||||
proc quit(conf: ConfigRef; msg: TMsgKind) {.gcsafe.} =
|
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.}:
|
{.gcsafe.}:
|
||||||
if stackTraceAvailable() and isNil(conf.writelnHook):
|
if stackTraceAvailable() and isNil(conf.writelnHook):
|
||||||
writeStackTrace()
|
writeStackTrace()
|
||||||
|
|
|
||||||
|
|
@ -576,6 +576,13 @@ proc isDefined*(conf: ConfigRef; symbol: string): bool =
|
||||||
osDragonfly, osMacosx}
|
osDragonfly, osMacosx}
|
||||||
else: discard
|
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 importantComments*(conf: ConfigRef): bool {.inline.} = conf.cmd in cmdDocLike + {cmdIdeTools}
|
||||||
proc usesWriteBarrier*(conf: ConfigRef): bool {.inline.} = conf.selectedGC >= gcRefc
|
proc usesWriteBarrier*(conf: ConfigRef): bool {.inline.} = conf.selectedGC >= gcRefc
|
||||||
|
|
||||||
|
|
@ -732,8 +739,7 @@ proc completeGeneratedFilePath*(conf: ConfigRef; f: AbsoluteFile,
|
||||||
try:
|
try:
|
||||||
createDir(subdir.string)
|
createDir(subdir.string)
|
||||||
except OSError:
|
except OSError:
|
||||||
writeLine(stdout, "cannot create directory: " & subdir.string)
|
conf.quitOrRaise "cannot create directory: " & subdir.string
|
||||||
quit(1)
|
|
||||||
result = subdir / RelativeFile f.string.splitPath.tail
|
result = subdir / RelativeFile f.string.splitPath.tail
|
||||||
#echo "completeGeneratedFilePath(", f, ") = ", result
|
#echo "completeGeneratedFilePath(", f, ") = ", result
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1011,7 +1011,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType,
|
||||||
when declared(deallocatedRefId):
|
when declared(deallocatedRefId):
|
||||||
let corrupt = deallocatedRefId(cast[pointer](f))
|
let corrupt = deallocatedRefId(cast[pointer](f))
|
||||||
if corrupt != 0:
|
if corrupt != 0:
|
||||||
quit "it's corrupt " & $corrupt
|
c.c.config.quitOrRaise "it's corrupt " & $corrupt
|
||||||
|
|
||||||
if f.kind == tyUntyped:
|
if f.kind == tyUntyped:
|
||||||
if aOrig != nil: put(c, f, aOrig)
|
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] == '?':
|
if i+1 < line.len and line[i] == '#' and line[i+1] == '?':
|
||||||
when defined(nimpretty):
|
when defined(nimpretty):
|
||||||
# XXX this is a bit hacky, but oh well...
|
# 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:
|
else:
|
||||||
inc(i, 2)
|
inc(i, 2)
|
||||||
while i < line.len and line[i] in Whitespace: inc(i)
|
while i < line.len and line[i] in Whitespace: inc(i)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue