summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorringabout <43030857+ringabout@users.noreply.github.com>2023-10-07 13:43:39 +0800
committerGitHub <noreply@github.com>2023-10-07 07:43:39 +0200
commitefa64aa49b11e93461626e84b9f67b6185f26e1f (patch)
tree89ebc44e3dc1eb09947580ce5901f2aa65443c79 /compiler
parentf111009e5dadceeab2fb076c968f8e18a5e495f8 (diff)
downloadNim-efa64aa49b11e93461626e84b9f67b6185f26e1f.tar.gz
fixes #22787; marks `var section` in the loop as reassign preventing cursor (#22800)
fixes #22787

---------

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Diffstat (limited to 'compiler')
-rw-r--r--compiler/varpartitions.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/varpartitions.nim b/compiler/varpartitions.nim
index 74bf63da8..957497bb6 100644
--- a/compiler/varpartitions.nim
+++ b/compiler/varpartitions.nim
@@ -823,6 +823,10 @@ proc computeLiveRanges(c: var Partitions; n: PNode) =
           registerVariable(c, child[i])
           #deps(c, child[i], last)
 
+        if c.inLoop > 0 and child[0].kind == nkSym: # bug #22787
+          let vid = variableId(c, child[0].sym)
+          if child[^1].kind != nkEmpty:
+            markAsReassigned(c, vid)
   of nkAsgn, nkFastAsgn, nkSinkAsgn:
     computeLiveRanges(c, n[0])
     computeLiveRanges(c, n[1])