the 'deprecated' pragma for modules now supports an error message
This commit is contained in:
parent
c34cb101b8
commit
8518683dc7
3 changed files with 12 additions and 3 deletions
|
|
@ -847,6 +847,8 @@ type
|
||||||
constraint*: PNode # additional constraints like 'lit|result'; also
|
constraint*: PNode # additional constraints like 'lit|result'; also
|
||||||
# misused for the codegenDecl pragma in the hope
|
# misused for the codegenDecl pragma in the hope
|
||||||
# it won't cause problems
|
# it won't cause problems
|
||||||
|
# for skModule the string literal to output for
|
||||||
|
# deprecated modules.
|
||||||
when defined(nimsuggest):
|
when defined(nimsuggest):
|
||||||
allUsages*: seq[TLineInfo]
|
allUsages*: seq[TLineInfo]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,10 @@ proc myImportModule(c: PContext, n: PNode): PSym =
|
||||||
result.info.fileIndex == n.info.fileIndex:
|
result.info.fileIndex == n.info.fileIndex:
|
||||||
localError(n.info, errGenerated, "A module cannot import itself")
|
localError(n.info, errGenerated, "A module cannot import itself")
|
||||||
if sfDeprecated in result.flags:
|
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)
|
suggestSym(n.info, result, c.graph.usageSym, false)
|
||||||
|
|
||||||
proc impMod(c: PContext; it: PNode) =
|
proc impMod(c: PContext; it: PNode) =
|
||||||
|
|
|
||||||
|
|
@ -620,8 +620,12 @@ proc markCompilerProc(s: PSym) =
|
||||||
incl(s.flags, sfUsed)
|
incl(s.flags, sfUsed)
|
||||||
registerCompilerProc(s)
|
registerCompilerProc(s)
|
||||||
|
|
||||||
proc deprecatedStmt(c: PContext; pragma: PNode) =
|
proc deprecatedStmt(c: PContext; outerPragma: PNode) =
|
||||||
let pragma = pragma[1]
|
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:
|
if pragma.kind != nkBracket:
|
||||||
localError(pragma.info, "list of key:value pairs expected"); return
|
localError(pragma.info, "list of key:value pairs expected"); return
|
||||||
for n in pragma:
|
for n in pragma:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue