diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-04-01 08:49:29 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-01 17:49:29 +0200 |
commit | 216fd59c44c7eb56431748389e3b2116692189a1 (patch) | |
tree | 247042a1f1a0d01fb5f2445f9513702f53240797 /compiler | |
parent | d3020af44d57316b3d913962a64a0949714d26f7 (diff) | |
download | Nim-216fd59c44c7eb56431748389e3b2116692189a1.tar.gz |
make `usage of foo is a user-defined error` more informative (#13833)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/suggest.nim | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/compiler/suggest.nim b/compiler/suggest.nim index ff58bc92f..d8da2a7a4 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -523,14 +523,16 @@ proc warnAboutDeprecated(conf: ConfigRef; info: TLineInfo; s: PSym) = proc userError(conf: ConfigRef; info: TLineInfo; s: PSym) = let pragmaNode = extractPragma(s) - + template bail(prefix: string) = + localError(conf, info, "$1usage of '$2' is an {.error.} defined at $3" % + [prefix, s.name.s, toFileLineCol(conf, s.ast.info)]) if pragmaNode != nil: for it in pragmaNode: if whichPragma(it) == wError and it.safeLen == 2 and it[1].kind in {nkStrLit..nkTripleStrLit}: - localError(conf, info, it[1].strVal & "; usage of '$1' is a user-defined error" % s.name.s) + bail(it[1].strVal & "; ") return - localError(conf, info, "usage of '$1' is a user-defined error" % s.name.s) + bail("") proc markOwnerModuleAsUsed(c: PContext; s: PSym) = var module = s |