diff options
author | LemonBoy <LemonBoy@users.noreply.github.com> | 2018-08-21 15:07:44 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-08-21 15:07:44 +0200 |
commit | cf20c4460c5b495a97b3f1f1d091f77832b89384 (patch) | |
tree | 3b47a9728d6acbce68ca360ffe203f05f0074914 /compiler/suggest.nim | |
parent | bbe5e8326b9f307e857b28d4b27fe9b1ec6a08c0 (diff) | |
download | Nim-cf20c4460c5b495a97b3f1f1d091f77832b89384.tar.gz |
More robust handling of deprecated pragmas (#8696)
Prevent `deprecated` annotations to "slip" up to the parent module and warn about unsupported annotations. Accidentally fixes #7867
Diffstat (limited to 'compiler/suggest.nim')
-rw-r--r-- | compiler/suggest.nim | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/compiler/suggest.nim b/compiler/suggest.nim index a21d64338..b52632c67 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -454,14 +454,23 @@ proc suggestSym*(conf: ConfigRef; info: TLineInfo; s: PSym; usageSym: var PSym; suggestResult(conf, symToSuggest(conf, s, isLocal=false, ideOutline, info, 100, PrefixMatch.None, false, 0)) proc warnAboutDeprecated(conf: ConfigRef; info: TLineInfo; s: PSym) = + var pragmaNode: PNode + if s.kind in routineKinds: - let n = s.ast[pragmasPos] - if n.kind != nkEmpty: - for it in n: - if whichPragma(it) == wDeprecated and it.safeLen == 2 and - it[1].kind in {nkStrLit..nkTripleStrLit}: - message(conf, info, warnDeprecated, it[1].strVal & "; " & s.name.s) - return + pragmaNode = s.ast[pragmasPos] + elif s.kind in {skType}: + # s.ast = nkTypedef / nkPragmaExpr / [nkSym, nkPragma] + pragmaNode = s.ast[0][1] + + doAssert pragmaNode == nil or pragmaNode.kind == nkPragma + + if pragmaNode != nil: + for it in pragmaNode: + if whichPragma(it) == wDeprecated and it.safeLen == 2 and + it[1].kind in {nkStrLit..nkTripleStrLit}: + message(conf, info, warnDeprecated, it[1].strVal & "; " & s.name.s) + return + message(conf, info, warnDeprecated, s.name.s) proc markUsed(conf: ConfigRef; info: TLineInfo; s: PSym; usageSym: var PSym) = |