summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-10-03 02:45:04 +0800
committerGitHub <noreply@github.com>2023-10-02 14:45:04 -0400
commit642ac0c1c31063ae966d8448c64c539203432e94 (patch)
tree77f478064fc468b83c77a3b3487d121a674b7bfb /compiler
parent49df69334e8c81354d604bbde05665d6c5450ddb (diff)
downloadNim-642ac0c1c31063ae966d8448c64c539203432e94.tar.gz
fixes #22753; Nimsuggest segfault with invalid assignment to table (#22781)
fixes #22753

## Future work
We should turn all the error nodes into nodes of a nkError kind, which
could be a industrious task. But perhaps we can add a special treatment
for error nodes to make the transition smooth.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/semexprs.nim2
-rw-r--r--compiler/semmagic.nim2
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 633a0cc26..8cdd16f02 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -1886,7 +1886,7 @@ proc semAsgn(c: PContext, n: PNode; mode=asgnNormal): PNode =
       result.add(n[1])
       if mode == noOverloadedSubscript:
         bracketNotFoundError(c, result)
-        return n
+        return errorNode(c, n)
       else:
         result = semExprNoType(c, result)
         return result
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index cb5e76e8c..b5990161e 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -66,7 +66,7 @@ proc semArrGet(c: PContext; n: PNode; flags: TExprFlags): PNode =
     x[0] = newIdentNode(getIdent(c.cache, "[]"), n.info)
     bracketNotFoundError(c, x)
     #localError(c.config, n.info, "could not resolve: " & $n)
-    result = n
+    result = errorNode(c, n)
 
 proc semArrPut(c: PContext; n: PNode; flags: TExprFlags): PNode =
   # rewrite `[]=`(a, i, x)  back to ``a[i] = x``.