summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authormetagn <metagngn@gmail.com>2024-09-27 07:23:29 +0300
committerGitHub <noreply@github.com>2024-09-27 06:23:29 +0200
commitfd379c2f9410d8baa2e0dc7819e5bf3134aa7605 (patch)
tree543e951026dfca3f1732a79bddec1156e47fdd15 /compiler
parent1bd5a4a99ed3fc6a77c3f8927d2d2292203af328 (diff)
downloadNim-fd379c2f9410d8baa2e0dc7819e5bf3134aa7605.tar.gz
fix nimsuggest crash with arrow type sugar (#24185)
fixes #24179 

The original fix made it so calls to `skError`/`skUnknown` (in this case
`->`, for some reason `sugar` couldn't be imported) returned an error
node, however this breaks tsug_accquote for some reason I don't
understand (it even parses as `tsug_accquote.discard`) so I've just
added a guard based on the stacktrace.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semexprs.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index f5b32637e..6a3b40111 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -890,6 +890,9 @@ proc analyseIfAddressTaken(c: PContext, n: PNode, isOutParam: bool): PNode =
 
 proc analyseIfAddressTakenInCall(c: PContext, n: PNode, isConverter = false) =
   checkMinSonsLen(n, 1, c.config)
+  if n[0].typ == nil:
+    # n[0] might be erroring node in nimsuggest
+    return
   const
     FakeVarParams = {mNew, mNewFinalize, mInc, ast.mDec, mIncl, mExcl,
       mSetLengthStr, mSetLengthSeq, mAppendStrCh, mAppendStrStr, mSwap,