mirror of
https://github.com/nim-lang/Nim.git
synced 2026-09-08 14:37:29 +00:00
* add astmsgs; add `declared in` msg for usage lint errors * fix test * fix tests/tools/tlinter.nim * std prefix
24 lines
996 B
Nim
24 lines
996 B
Nim
# this module avoids ast depending on msgs or vice versa
|
|
import std/strutils
|
|
import options, ast, msgs
|
|
|
|
proc addDeclaredLoc*(result: var string, conf: ConfigRef; sym: PSym) =
|
|
result.add " [$1 declared in $2]" % [sym.kind.toHumanStr, toFileLineCol(conf, sym.info)]
|
|
|
|
proc addDeclaredLocMaybe*(result: var string, conf: ConfigRef; sym: PSym) =
|
|
if optDeclaredLocs in conf.globalOptions and sym != nil:
|
|
addDeclaredLoc(result, conf, sym)
|
|
|
|
proc addDeclaredLoc*(result: var string, conf: ConfigRef; typ: PType) =
|
|
# xxx figure out how to resolve `tyGenericParam`, e.g. for
|
|
# proc fn[T](a: T, b: T) = discard
|
|
# fn(1.1, "a")
|
|
let typ = typ.skipTypes(abstractInst + {tyStatic} - {tyRange})
|
|
result.add " [$1" % typ.kind.toHumanStr
|
|
if typ.sym != nil:
|
|
result.add " declared in " & toFileLineCol(conf, typ.sym.info)
|
|
result.add "]"
|
|
|
|
proc addDeclaredLocMaybe*(result: var string, conf: ConfigRef; typ: PType) =
|
|
if optDeclaredLocs in conf.globalOptions: addDeclaredLoc(result, conf, typ)
|