diff --git a/compiler/injectdestructors.nim b/compiler/injectdestructors.nim index 82c4b9bef0..1f2cff7e5f 100644 --- a/compiler/injectdestructors.nim +++ b/compiler/injectdestructors.nim @@ -165,7 +165,8 @@ proc isLastReadImpl(n: PNode; c: var Con; scope: var Scope): bool = template hasDestructorOrAsgn(c: var Con, typ: PType): bool = # bug #23354; an object type could have a non-trivial assignements when it is passed to a sink parameter - hasDestructor(c, typ) or (typ.kind == tyObject and not isTrivial(getAttachedOp(c.graph, typ, attachedAsgn))) + hasDestructor(c, typ) or (c.graph.config.selectedGC in {gcArc, gcOrc, gcAtomicArc} and + typ.kind == tyObject and not isTrivial(getAttachedOp(c.graph, typ, attachedAsgn))) proc isLastRead(n: PNode; c: var Con; s: var Scope): bool = if not hasDestructorOrAsgn(c, n.typ): return true diff --git a/tests/arc/t24760.nim b/tests/arc/t24760.nim index 4eb65a3774..cd6f60c252 100644 --- a/tests/arc/t24760.nim +++ b/tests/arc/t24760.nim @@ -1,5 +1,5 @@ discard """ - matrix: "--mm:refc; --mm:orc" + matrix: "--mm:orc" errormsg: "=dup' is not available for type , which is inferred from unavailable '=copy'; requires a copy because it's not the last read of 'b'; another read is done here: t24760.nim(19, 8); routine: g" """