diff options
author | Araq <rumpf_a@web.de> | 2018-04-06 11:56:53 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2018-04-06 11:59:49 +0200 |
commit | 8518683dc7f76465b41bd0ccf19f9fab06cd5e32 (patch) | |
tree | 46aa29d67df12536eee7a08b67822a425b1ea1b2 | |
parent | c34cb101b8621d52680892ae4041dff6541f1c0a (diff) | |
download | Nim-8518683dc7f76465b41bd0ccf19f9fab06cd5e32.tar.gz |
the 'deprecated' pragma for modules now supports an error message
-rw-r--r-- | compiler/ast.nim | 2 | ||||
-rw-r--r-- | compiler/importer.nim | 5 | ||||
-rw-r--r-- | compiler/pragmas.nim | 8 |
3 files changed, 12 insertions, 3 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim index a28a7e7e3..ad4d6fed8 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -847,6 +847,8 @@ type constraint*: PNode # additional constraints like 'lit|result'; also # misused for the codegenDecl pragma in the hope # it won't cause problems + # for skModule the string literal to output for + # deprecated modules. when defined(nimsuggest): allUsages*: seq[TLineInfo] diff --git a/compiler/importer.nim b/compiler/importer.nim index 3d7f62464..f4903e6c4 100644 --- a/compiler/importer.nim +++ b/compiler/importer.nim @@ -148,7 +148,10 @@ proc myImportModule(c: PContext, n: PNode): PSym = result.info.fileIndex == n.info.fileIndex: localError(n.info, errGenerated, "A module cannot import itself") if sfDeprecated in result.flags: - message(n.info, warnDeprecated, result.name.s) + if result.constraint != nil: + message(n.info, warnDeprecated, result.constraint.strVal & "; " & result.name.s) + else: + message(n.info, warnDeprecated, result.name.s) suggestSym(n.info, result, c.graph.usageSym, false) proc impMod(c: PContext; it: PNode) = diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 78ded578f..d5fed7640 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -620,8 +620,12 @@ proc markCompilerProc(s: PSym) = incl(s.flags, sfUsed) registerCompilerProc(s) -proc deprecatedStmt(c: PContext; pragma: PNode) = - let pragma = pragma[1] +proc deprecatedStmt(c: PContext; outerPragma: PNode) = + let pragma = outerPragma[1] + if pragma.kind in {nkStrLit..nkTripleStrLit}: + incl(c.module.flags, sfDeprecated) + c.module.constraint = getStrLitNode(c, outerPragma) + return if pragma.kind != nkBracket: localError(pragma.info, "list of key:value pairs expected"); return for n in pragma: |