diff options
author | Neelesh Chandola <neelesh.chandola@outlook.com> | 2019-01-09 00:14:47 +0530 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-01-08 19:44:47 +0100 |
commit | fb26b95f815b5426e0a8aad98ca0ff018ef1f4db (patch) | |
tree | 9ef02c1e5745922ee180cb6d680cfe10c0f4129a /compiler | |
parent | d0366c519487610ff26d28175e98a9c3ef178670 (diff) | |
download | Nim-fb26b95f815b5426e0a8aad98ca0ff018ef1f4db.tar.gz |
{.deprecated: msg.} now works for vars and lets (#10234)
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/pragmas.nim | 2 | ||||
-rw-r--r-- | compiler/suggest.nim | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 39b58d0b1..bb5707cd5 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -881,7 +881,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int, of wExplain: sym.flags.incl sfExplain of wDeprecated: - if sym != nil and sym.kind in routineKinds + {skType}: + if sym != nil and sym.kind in routineKinds + {skType, skVar, skLet}: if it.kind in nkPragmaCallKinds: discard getStrLitNode(c, it) incl(sym.flags, sfDeprecated) elif sym != nil and sym.kind != skModule: diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 144b86224..f3f960136 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -456,13 +456,17 @@ proc suggestSym*(conf: ConfigRef; info: TLineInfo; s: PSym; usageSym: var PSym; proc extractPragma(s: PSym): PNode = if s.kind in routineKinds: result = s.ast[pragmasPos] - elif s.kind in {skType}: + elif s.kind in {skType, skVar, skLet}: # s.ast = nkTypedef / nkPragmaExpr / [nkSym, nkPragma] result = s.ast[0][1] doAssert result == nil or result.kind == nkPragma proc warnAboutDeprecated(conf: ConfigRef; info: TLineInfo; s: PSym) = - let pragmaNode = if s.kind == skEnumField: extractPragma(s.owner) else: extractPragma(s) + var pragmaNode: PNode + if optOldAst in conf.options and s.kind in {skVar, skLet}: + pragmaNode = nil + else: + pragmaNode = if s.kind == skEnumField: extractPragma(s.owner) else: extractPragma(s) let name = if s.kind == skEnumField and sfDeprecated notin s.flags: "enum '" & s.owner.name.s & "' which contains field '" & s.name.s & "'" else: s.name.s |