From 0b4c5ba1b51a995984fde632e442f0bbc4f6f37a Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Fri, 19 Sep 2025 21:31:08 +0800 Subject: [PATCH] fixes `asyncthreadpool`; `refc` having troubles with closures hooks --- compiler/injectdestructors.nim | 3 ++- tests/arc/t24760.nim | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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" """