make it easier to figure out how to debug issues (#14477)

This commit is contained in:
Timothee Cour 2020-05-28 01:19:12 -07:00 • committed by GitHub
commit fe7a2d60f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 10 deletions

View file

@ -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]