Skip to content

Commit

Permalink
fixes #13105 (#13138)
Browse files Browse the repository at this point in the history
  • Loading branch information
Araq authored Jan 14, 2020
1 parent d568488 commit 9fc04a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/ccgexprs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions tests/destructor/tarc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ discard """
Success
@["a", "b", "c"]
Hello
1
2
0'''
cmd: '''nim c --gc:arc $file'''
"""
Expand Down Expand Up @@ -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

0 comments on commit 9fc04a5

Please sign in to comment.