diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-05-05 19:34:14 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-05-05 19:34:14 +0300 |
commit | f0be93bfa2cb49ab88595478efb4457391d49a31 (patch) | |
tree | 5ddf02bbf592c4efea5bdd3266dae44959bb1143 /compiler | |
parent | 11ee2261929117972256fc2117101ead3dfff11d (diff) | |
download | Nim-f0be93bfa2cb49ab88595478efb4457391d49a31.tar.gz |
handle invalid data in --def
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/suggest.nim | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/suggest.nim b/compiler/suggest.nim index 273347ef3..18e6dbddf 100644 --- a/compiler/suggest.nim +++ b/compiler/suggest.nim @@ -272,6 +272,7 @@ proc addToSourceMap(sym: Psym, info: TLineInfo) = gSourceMaps[info.fileIndex].lines[info.line].entries.add(TEntry(pos: info.col, sym: sym)) proc defFromLine(entries: var seq[TEntry], col: int32) = + if entries == nil: return # The sorting is done lazily here on purpose. # No need to pay the price for it unless the user requests # "goto definition" on a particular line @@ -288,8 +289,10 @@ proc defFromLine(entries: var seq[TEntry], col: int32) = return proc defFromSourceMap*(i: TLineInfo) = - InternalAssert i.fileIndex < gSourceMaps.len and - i.line < gSourceMaps[i.fileIndex].lines.len + if not ((i.fileIndex < gSourceMaps.len) and + (gSourceMaps[i.fileIndex].lines != nil) and + (i.line < gSourceMaps[i.fileIndex].lines.len)): return + defFromLine(gSourceMaps[i.fileIndex].lines[i.line].entries, i.col) proc suggestSym*(n: PNode, s: PSym) {.inline.} = |