From ca35095d8d8d642de3f22b2ae741537f3d161003 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Thu, 21 May 2020 21:00:26 -0700 Subject: [PATCH] all compiler messages work with hint:msgorigin --- compiler/msgs.nim | 26 +++++++++++--------------- compiler/semdata.nim | 3 ++- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 414042c01b16d..aeb428343cc00 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -577,14 +577,18 @@ template internalError*(conf: ConfigRef; errMsg: string) = const info2 = instantiationInfo(-1, fullPaths = true) internalErrorImpl(conf, unknownLineInfo, errMsg, info2) -# PRTEMP -template assertNotNil*(conf: ConfigRef; e): untyped = - if e == nil: internalError(conf, $instantiationInfo()) - e - -# PRTEMP template internalAssert*(conf: ConfigRef, e: bool) = - if not e: internalError(conf, $instantiationInfo()) + # xxx merge with globalAssert from PR #14324 + const info2 = instantiationInfo(-1, fullPaths = true) + if not e: + let arg = info2.toFileLineCol + internalErrorImpl(conf, unknownLineInfo, arg, info2) + +template lintReport*(conf: ConfigRef; info: TLineInfo, beau, got: string) = + const info2 = instantiationInfo(-1, fullPaths = true) + let m = "'$2' should be: '$1'" % [beau, got] + let msg = if optStyleError in conf.globalOptions: errGenerated else: hintName + liMessage(conf, info, msg, m, doNothing, info2) proc quotedFilename*(conf: ConfigRef; i: TLineInfo): Rope = if i.fileIndex.int32 < 0: @@ -609,11 +613,3 @@ proc listHints*(conf: ConfigRef) = if hint in conf.notes: "x" else: " ", lineinfos.HintsToStr[ord(hint) - ord(hintMin)] ]) - -# PRTEMP -proc lintReport*(conf: ConfigRef; info: TLineInfo, beau, got: string) = - let m = "'$2' should be: '$1'" % [beau, got] - if optStyleError in conf.globalOptions: - localError(conf, info, m) - else: - message(conf, info, hintName, m) diff --git a/compiler/semdata.nim b/compiler/semdata.nim index 278384fc44ed9..5a2c08de266b8 100644 --- a/compiler/semdata.nim +++ b/compiler/semdata.nim @@ -321,7 +321,8 @@ proc makeTypeDesc*(c: PContext, typ: PType): PType = proc makeTypeSymNode*(c: PContext, typ: PType, info: TLineInfo): PNode = let typedesc = newTypeS(tyTypeDesc, c) incl typedesc.flags, tfCheckedForDestructor - typedesc.addSonSkipIntLit(assertNotNil(c.config, typ)) + internalAssert(c.config, typ != nil) + typedesc.addSonSkipIntLit(typ) let sym = newSym(skType, c.cache.idAnon, getCurrOwner(c), info, c.config.options).linkTo(typedesc) return newSymNode(sym, info)