Skip to content

Commit

Permalink
all compiler messages work with hint:msgorigin
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour committed May 22, 2020
1 parent d528c22 commit ca35095
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
26 changes: 11 additions & 15 deletions compiler/msgs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
3 changes: 2 additions & 1 deletion compiler/semdata.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ca35095

Please sign in to comment.