fixes #22218; avoids cursor when copy is disabled (#23209)

fixes #22218

(cherry picked from commit b2f79df81c)
This commit is contained in:
ringabout
2024-01-19 04:47:13 +08:00
committed by narimiran
parent a1b310d186
commit 5a2cd98867
2 changed files with 28 additions and 1 deletions

View File

@@ -983,7 +983,9 @@ proc computeCursors*(s: PSym; n: PNode; g: ModuleGraph) =
if v.flags * {ownsData, preventCursor, isConditionallyReassigned} == {} and
v.sym.kind notin {skParam, skResult} and
v.sym.flags * {sfThread, sfGlobal} == {} and hasDestructor(v.sym.typ) and
v.sym.typ.skipTypes({tyGenericInst, tyAlias}).kind != tyOwned:
v.sym.typ.skipTypes({tyGenericInst, tyAlias}).kind != tyOwned and
(getAttachedOp(g, v.sym.typ, attachedAsgn) == nil or
sfError notin getAttachedOp(g, v.sym.typ, attachedAsgn).flags):
let rid = root(par, i)
if par.s[rid].con.kind == isRootOf and dangerousMutation(par.graphs[par.s[rid].con.graphIndex], par.s[i]):
discard "cannot cursor into a graph that is mutated"