diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim index f9cd3b6f37..7b975268cd 100644 --- a/compiler/modulegraphs.nim +++ b/compiler/modulegraphs.nim @@ -606,10 +606,16 @@ proc setHookDisamb*(g: ModuleGraph; hook: PSym; opName: string; typ: PType) = break hook.disamb = h -proc hasDisabledAsgn*(g: ModuleGraph; t: PType): bool = - let op = getAttachedOp(g, t, attachedAsgn) +proc hasDisabledOp(g: ModuleGraph; t: PType; kind: TTypeAttachedOp): bool = + let op = getAttachedOp(g, t, kind) result = op != nil and sfError in op.flags +proc hasDisabledAsgn*(g: ModuleGraph; t: PType): bool = + result = hasDisabledOp(g, t, attachedAsgn) + +proc hasDisabledDup*(g: ModuleGraph; t: PType): bool = + result = hasDisabledOp(g, t, attachedDup) + proc copyTypeProps*(g: ModuleGraph; module: int; dest, src: PType) = for k in low(TTypeAttachedOp)..high(TTypeAttachedOp): let op = getAttachedOp(g, src, k) diff --git a/compiler/varpartitions.nim b/compiler/varpartitions.nim index 3a01eb0bbd..87dcf76f9d 100644 --- a/compiler/varpartitions.nim +++ b/compiler/varpartitions.nim @@ -1024,8 +1024,8 @@ proc computeCursors*(s: PSym; n: PNode; g: ModuleGraph) = v.sym.flags * {sfThread, sfGlobal} == {} and (hasDestructor(v.sym.typ) or (jsCursors and jsDeepCopied(v.sym.typ))) and 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): + not hasDisabledAsgn(g, v.sym.typ) and + not hasDisabledDup(g, v.sym.typ): 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" diff --git a/tests/arc/torcmisc.nim b/tests/arc/torcmisc.nim index fc0eaf2ff7..079d99c133 100644 --- a/tests/arc/torcmisc.nim +++ b/tests/arc/torcmisc.nim @@ -65,3 +65,17 @@ method handleConn*(myParam: PubSub, proto: string) {.base, async.} = myParam.peers.withValue(conn.peerInfo.peerId, peer): let peerB = peer[] + + + +block: + type M = object + + proc `=dup`(_: M): M {.error.} + proc take(_: sink M) = discard + + proc test() = + var value: M + take(value) + + test()