From 216fd59c44c7eb56431748389e3b2116692189a1 Mon Sep 17 00:00:00 2001 From: Timothee Cour Date: Wed, 1 Apr 2020 08:49:29 -0700 Subject: [PATCH] make `usage of foo is a user-defined error` more informative (#13833) --- compiler/suggest.nim | 8 +++++--- 1 file 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