system.deepCopy should show old behaviour

This commit is contained in:
Andreas Rumpf 2016-11-28 11:03:01 +01:00
commit 734443d725

View file

@ -134,7 +134,7 @@ proc genericDeepCopyAux(dest, src: pointer, mt: PNimType; tab: var PtrTable) =
else: else:
let z = tab.get(s2) let z = tab.get(s2)
if z == nil: if z == nil:
when declared(usrToCell) and false: when declared(usrToCell):
let x = usrToCell(s2) let x = usrToCell(s2)
let realType = x.typ let realType = x.typ
let z = newObj(realType, realType.base.size) let z = newObj(realType, realType.base.size)
@ -142,6 +142,11 @@ proc genericDeepCopyAux(dest, src: pointer, mt: PNimType; tab: var PtrTable) =
tab.put(s2, z) tab.put(s2, z)
genericDeepCopyAux(z, s2, realType.base, tab) genericDeepCopyAux(z, s2, realType.base, tab)
else: else:
when false:
# addition check disabled
let x = usrToCell(s2)
let realType = x.typ
sysAssert realType == mt, " types do differ"
# this version should work for any possible GC: # this version should work for any possible GC:
let size = if mt.base.kind == tyObject: cast[ptr PNimType](s2)[].size else: mt.base.size let size = if mt.base.kind == tyObject: cast[ptr PNimType](s2)[].size else: mt.base.size
let z = newObj(mt, size) let z = newObj(mt, size)