summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2021-06-24 18:37:04 +0200
committerGitHub <noreply@github.com>2021-06-24 18:37:04 +0200
commit16038d44f6b246c5f39d1a8609a8c45f2cd005a4 (patch)
tree9e5ab7c5dffd63c04b9b91e60c18e5122a3b8bba
parent565e07a9936657fa356777eec5f0f52b2d5d7e02 (diff)
downloadNim-16038d44f6b246c5f39d1a8609a8c45f2cd005a4.tar.gz
fixes #18320 (#18343)
* TSymFlag has 47 flags already

* fixes #18320
-rw-r--r--compiler/ast.nim2
-rw-r--r--compiler/varpartitions.nim8
2 files changed, 6 insertions, 4 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 8bb8de1d6..56043692f 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -229,7 +229,7 @@ type
   TNodeKinds* = set[TNodeKind]
 
 type
-  TSymFlag* = enum    # 46 flags!
+  TSymFlag* = enum    # 47 flags!
     sfUsed,           # read access of sym (for warnings) or simply used
     sfExported,       # symbol is exported from module
     sfFromGeneric,    # symbol is instantiation of a generic; this is needed
diff --git a/compiler/varpartitions.nim b/compiler/varpartitions.nim
index 697dd2b1d..213c3b80e 100644
--- a/compiler/varpartitions.nim
+++ b/compiler/varpartitions.nim
@@ -51,6 +51,7 @@ type
   SubgraphFlag = enum
     isMutated, # graph might be mutated
     isMutatedDirectly, # graph is mutated directly by a non-var parameter.
+    isMutatedByVarParam, # graph is mutated by a var parameter.
     connectsConstParam # graph is connected to a non-var parameter.
 
   VarFlag = enum
@@ -184,7 +185,7 @@ proc potentialMutation(v: var Partitions; s: PSym; level: int; info: TLineInfo)
                     {isMutated, isMutatedDirectly}
                   elif s.typ.kind == tyVar and level <= 1:
                     # varParam[i] = v is different from varParam[i][] = v
-                    {}
+                    {isMutatedByVarParam}
                   else:
                     {isMutated}
                 else:
@@ -878,7 +879,7 @@ proc computeGraphPartitions*(s: PSym; n: PNode; g: ModuleGraph; goals: set[Goal]
 
 proc dangerousMutation(g: MutationInfo; v: VarIndex): bool =
   #echo "range ", v.aliveStart, " .. ", v.aliveEnd, " ", v.sym
-  if isMutated in g.flags:
+  if {isMutated, isMutatedByVarParam} * g.flags != {}:
     for m in g.mutations:
       #echo "mutation ", m
       if m in v.aliveStart..v.aliveEnd:
@@ -941,4 +942,5 @@ proc computeCursors*(s: PSym; n: PNode; g: ModuleGraph) =
         discard "cannot cursor into a graph that is mutated"
       else:
         v.sym.flags.incl sfCursor
-        #echo "this is now a cursor ", v.sym, " ", par.s[rid].flags, " ", g.config $ v.sym.info
+        when false:
+          echo "this is now a cursor ", v.sym, " ", par.s[rid].flags, " ", g.config $ v.sym.info