diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 13e075bf4bda..aaf60a6cbff2 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -336,7 +336,7 @@ proc genAssignment(p: BProc, dest, src: TLoc, flags: TAssignmentFlags) = else: linefmt(p, cpsStmts, "$1 = $2;$n", [rdLoc(dest), rdLoc(src)]) of tyArray: - if containsGarbageCollectedRef(dest.t): + if containsGarbageCollectedRef(dest.t) and p.config.selectedGC notin {gcArc, gcOrc, gcHooks}: genGenericAsgn(p, dest, src, flags) else: linefmt(p, cpsStmts, diff --git a/tests/destructor/tarc.nim b/tests/destructor/tarc.nim index 58642d09fc72..1acc95fadec7 100644 --- a/tests/destructor/tarc.nim +++ b/tests/destructor/tarc.nim @@ -4,6 +4,8 @@ discard """ Success @["a", "b", "c"] Hello +1 +2 0''' cmd: '''nim c --gc:arc $file''' """ @@ -126,4 +128,20 @@ proc bug13119 = bug13119() +# bug #13105 + +type + Result[T, E] = object + a: T + b: E + D = ref object + x: int + R = Result[D, int] + +proc bug13105 = + for n in [R(b: 1), R(b: 2)]: + echo n.b + +bug13105() + echo getOccupiedMem() - startMem