From 07f4e8a4ed2624b92a6cb5fc578e80619b947919 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Sun, 22 Apr 2018 00:12:43 +0200 Subject: [PATCH] new 'var T' error messages with hyperlinks; closes #7373 --- compiler/msgs.nim | 3 +++ compiler/semexprs.nim | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 06f333cef8b1..f08d2d2aff60 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -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, diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim index 8e223ed90153..279b6cc5774c 100644 --- a/compiler/semexprs.nim +++ b/compiler/semexprs.nim @@ -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]