Fixed copying of nil seq in JS

This commit is contained in:
Yuriy Glukhov 2015-12-16 15:25:58 +02:00
commit 62422b93c6

View file

@ -533,6 +533,10 @@ proc nimCopy(dest, src: JSRef, ti: PNimType): JSRef =
nimCopyAux(result, src, ti.node) nimCopyAux(result, src, ti.node)
of tySequence, tyArrayConstr, tyOpenArray, tyArray: of tySequence, tyArrayConstr, tyOpenArray, tyArray:
asm """ asm """
if (`src` === null) {
`result` = null;
}
else {
if (`dest` === null || `dest` === undefined) { if (`dest` === null || `dest` === undefined) {
`dest` = new Array(`src`.length); `dest` = new Array(`src`.length);
} }
@ -543,6 +547,7 @@ proc nimCopy(dest, src: JSRef, ti: PNimType): JSRef =
for (var i = 0; i < `src`.length; ++i) { for (var i = 0; i < `src`.length; ++i) {
`result`[i] = nimCopy(`result`[i], `src`[i], `ti`.base); `result`[i] = nimCopy(`result`[i], `src`[i], `ti`.base);
} }
}
""" """
of tyString: of tyString:
asm """ asm """