summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authoralaviss <alaviss@users.noreply.github.com>2018-12-26 03:08:16 +0700
committerAndreas Rumpf <rumpf_a@web.de>2018-12-25 21:08:16 +0100
commit58d293d6a98b56ed4b309491f09492618c3fa9ec (patch)
treee1cbc7e32ebbd80342056afabd1eda9c35d5f49b /compiler/semstmts.nim
parent5f2b66751ac0a3115e6b4760f067332e80264195 (diff)
downloadNim-58d293d6a98b56ed4b309491f09492618c3fa9ec.tar.gz
fixes nim-lang/nimsuggest#76 (#10093)
* nimsuggest: prevent out-of-bound access

* fixes nim-lang/nimsuggest#76

* undo tester changes
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 4b714e1f3..9016fed2b 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -315,7 +315,17 @@ proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym =
     result = semIdentWithPragma(c, kind, n, {})
     if result.owner.kind == skModule:
       incl(result.flags, sfGlobal)
-  suggestSym(c.config, n.info, result, c.graph.usageSym)
+  let info = case n.kind
+             of nkPostfix:
+               n.sons[1].info
+             of nkPragmaExpr:
+               if n.sons[0].kind == nkPostfix:
+                 n.sons[0].sons[1].info
+               else:
+                 n.sons[0].info
+             else:
+               n.info
+  suggestSym(c.config, info, result, c.graph.usageSym)
 
 proc checkNilable(c: PContext; v: PSym) =
   if {sfGlobal, sfImportC} * v.flags == {sfGlobal} and