diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-09-01 16:57:34 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-09-01 16:57:34 +0200 |
commit | 11f7eb2d9b2ff22053aa6e3d442f43922842d5e6 (patch) | |
tree | ec8b8e7a79e0f972a103503c01465fc5caa3a6c5 | |
parent | 9c444039340c43dd3db2d2901673260b64b604a7 (diff) | |
download | Nim-11f7eb2d9b2ff22053aa6e3d442f43922842d5e6.tar.gz |
fixes #4689
-rw-r--r-- | lib/system/channels.nim | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/system/channels.nim b/lib/system/channels.nim index 68c0e32d2..caa709229 100644 --- a/lib/system/channels.nim +++ b/lib/system/channels.nim @@ -124,8 +124,7 @@ proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, of tyObject: # copy type field: var pint = cast[ptr PNimType](dest) - # XXX use dynamic type here! - pint[] = mt + pint[] = cast[ptr PNimType](src)[] if mt.base != nil: storeAux(dest, src, mt.base, t, mode) storeAux(dest, src, mt.node, t, mode) @@ -144,13 +143,12 @@ proc storeAux(dest, src: pointer, mt: PNimType, t: PRawChannel, else: unsureAsgnRef(x, nil) else: + let size = if mt.base.kind == tyObject: cast[ptr PNimType](s)[].size + else: mt.base.size if mode == mStore: - x[] = alloc(t.region, mt.base.size) + x[] = alloc(t.region, size) else: - # XXX we should use the dynamic type here too, but that is not stored - # in the inbox at all --> use source[]'s object type? but how? we need - # a tyRef to the object! - var obj = newObj(mt, mt.base.size) + var obj = newObj(mt, size) unsureAsgnRef(x, obj) storeAux(x[], s, mt.base, t, mode) if mode != mStore: dealloc(t.region, s) |