Skip to content

Commit

Permalink
new 'var T' error messages with hyperlinks; closes #7373
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq committed Apr 21, 2018
1 parent b43025b commit 07f4e8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import
options, strutils, os, tables, ropes, platform, terminal, macros

const
explanationsBaseUrl* = "https://nim-lang.org/docs/manual"

type
TMsgKind* = enum
errUnknown, errInternal, errIllFormedAstX, errCannotOpenFile, errGenerated,
Expand Down
8 changes: 4 additions & 4 deletions compiler/semexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1342,11 +1342,11 @@ proc takeImplicitAddr(c: PContext, n: PNode; isLent: bool): PNode =
let root = exprRoot(n)
if root != nil and root.owner == c.p.owner:
if root.kind in {skLet, skVar, skTemp} and sfGlobal notin root.flags:
localError(n.info, "'$1' escapes its stack frame; context: '$2'" % [
root.name.s, renderTree(n, {renderNoComments})])
localError(n.info, "'$1' escapes its stack frame; context: '$2'; see $3/var_t_return.html" % [
root.name.s, renderTree(n, {renderNoComments}), explanationsBaseUrl])
elif root.kind == skParam and root.position != 0:
localError(n.info, "'$1' is not the first parameter; context: '$2'" % [
root.name.s, renderTree(n, {renderNoComments})])
localError(n.info, "'$1' is not the first parameter; context: '$2'; see $3/var_t_return.html" % [
root.name.s, renderTree(n, {renderNoComments}), explanationsBaseUrl])
case n.kind
of nkHiddenAddr, nkAddr: return n
of nkHiddenDeref, nkDerefExpr: return n.sons[0]
Expand Down

0 comments on commit 07f4e8a

Please sign in to comment.