make it easier to figure out how to debug issues (#14477)
This commit is contained in:
parent
e62ccaa4dc
commit
fe7a2d60f9
6 changed files with 64 additions and 10 deletions
|
|
@ -13,7 +13,17 @@
|
|||
import ropes, tables, pathutils
|
||||
|
||||
const
|
||||
explanationsBaseUrl* = "https://nim-lang.org/docs"
|
||||
explanationsBaseUrl* = "https://nim-lang.github.io/Nim"
|
||||
# was: "https://nim-lang.org/docs" but we're now usually showing devel docs
|
||||
# instead of latest release docs.
|
||||
|
||||
proc createDocLink*(urlSuffix: string): string =
|
||||
# os.`/` is not appropriate for urls.
|
||||
result = explanationsBaseUrl
|
||||
if urlSuffix.len > 0 and urlSuffix[0] == '/':
|
||||
result.add urlSuffix
|
||||
else:
|
||||
result.add "/" & urlSuffix
|
||||
|
||||
type
|
||||
TMsgKind* = enum
|
||||
|
|
|
|||
|
|
@ -385,9 +385,10 @@ proc quit(conf: ConfigRef; msg: TMsgKind) {.gcsafe.} =
|
|||
if stackTraceAvailable() and isNil(conf.writelnHook):
|
||||
writeStackTrace()
|
||||
else:
|
||||
styledMsgWriteln(fgRed, "No stack traceback available\n" &
|
||||
"To create a stacktrace, rerun compilation with ./koch temp " &
|
||||
conf.command & " <file>")
|
||||
styledMsgWriteln(fgRed, """
|
||||
No stack traceback available
|
||||
To create a stacktrace, rerun compilation with './koch temp $1 <file>', see $2 for details""" %
|
||||
[conf.command, "intern.html#debugging-the-compiler".createDocLink])
|
||||
quit 1
|
||||
|
||||
proc handleError(conf: ConfigRef; msg: TMsgKind, eh: TErrorHandling, s: string) =
|
||||
|
|
|
|||
|
|
@ -1572,12 +1572,13 @@ proc takeImplicitAddr(c: PContext, n: PNode; isLent: bool): PNode =
|
|||
# return a view into the first argument (if there is one):
|
||||
let root = exprRoot(n)
|
||||
if root != nil and root.owner == c.p.owner:
|
||||
template url: string = "var_t_return.html".createDocLink
|
||||
if root.kind in {skLet, skVar, skTemp} and sfGlobal notin root.flags:
|
||||
localError(c.config, n.info, "'$1' escapes its stack frame; context: '$2'; see $3/var_t_return.html" % [
|
||||
root.name.s, renderTree(n, {renderNoComments}), explanationsBaseUrl])
|
||||
localError(c.config, n.info, "'$1' escapes its stack frame; context: '$2'; see $3" % [
|
||||
root.name.s, renderTree(n, {renderNoComments}), url])
|
||||
elif root.kind == skParam and root.position != 0:
|
||||
localError(c.config, n.info, "'$1' is not the first parameter; context: '$2'; see $3/var_t_return.html" % [
|
||||
root.name.s, renderTree(n, {renderNoComments}), explanationsBaseUrl])
|
||||
localError(c.config, n.info, "'$1' is not the first parameter; context: '$2'; see $3" % [
|
||||
root.name.s, renderTree(n, {renderNoComments}), url])
|
||||
case n.kind
|
||||
of nkHiddenAddr, nkAddr: return n
|
||||
of nkDerefExpr: return n[0]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue