This commit is contained in:
Andreas Rumpf
2023-07-06 15:15:50 +02:00
committed by GitHub
parent dfa0d2569e
commit a15db5d60b
2 changed files with 17 additions and 2 deletions

View File

@@ -2357,8 +2357,11 @@ proc genMove(p: BProc; n: PNode; d: var TLoc) =
linefmt(p, cpsStmts, "}$n$1.len = $2.len; $1.p = $2.p;$n", [rdLoc(a), rdLoc(src)])
else:
if d.k == locNone: getTemp(p, n.typ, d)
genAssignment(p, d, a, {})
if p.config.selectedGC notin {gcArc, gcAtomicArc, gcOrc}:
if p.config.selectedGC in {gcArc, gcAtomicArc, gcOrc}:
genAssignment(p, d, a, {})
else:
let flags = if not canMove(p, n[1], d): {needToCopy} else: {}
genAssignment(p, d, a, flags)
resetLoc(p, a)
proc genDestroy(p: BProc; n: PNode) =

View File

@@ -27,3 +27,15 @@ block: # bug #17812
proc `$`(o: MyObj): string = o.repr
doAssert ($MyObj()).len > 0
# bug #22175
type Xxx = object
value: string
proc complete(xxx: ref Xxx, v: sink string) =
xxx.value = move(v)
let yyy = (ref Xxx)()
yyy.complete("test")