don't raise index defects on malformed ast (#15278)

* don't raise index defects on malformed ast

* style
This commit is contained in:
Andy Davidoff
2020-09-07 14:04:07 -04:00
committed by GitHub
parent e08b802d79
commit 0b74d26d0c
2 changed files with 14 additions and 6 deletions

View File

@@ -495,9 +495,14 @@ proc updateDefaultParams(call: PNode) =
proc getCallLineInfo(n: PNode): TLineInfo =
case n.kind
of nkAccQuoted, nkBracketExpr, nkCall, nkCallStrLit, nkCommand:
getCallLineInfo(n[0])
of nkDotExpr: getCallLineInfo(n[1])
else: n.info
if len(n) > 0:
return getCallLineInfo(n[0])
of nkDotExpr:
if len(n) > 1:
return getCallLineInfo(n[1])
else:
discard
result = n.info
proc semResolvedCall(c: PContext, x: TCandidate,
n: PNode, flags: TExprFlags): PNode =

View File

@@ -324,11 +324,14 @@ proc semIdentDef(c: PContext, n: PNode, kind: TSymKind): PSym =
proc getLineInfo(n: PNode): TLineInfo =
case n.kind
of nkPostfix:
getLineInfo(n[1])
if len(n) > 1:
return getLineInfo(n[1])
of nkAccQuoted, nkPragmaExpr:
getLineInfo(n[0])
if len(n) > 0:
return getLineInfo(n[0])
else:
n.info
discard
result = n.info
let info = getLineInfo(n)
suggestSym(c.config, info, result, c.graph.usageSym)