New seq slots are now zeroed when expanding the seq via invokeNewSeq
or extendSeq, making the behaviour consistent with setLen and
newSeq, and also fixing crashes with marshal caused by the
uninitialized memory.
Details
Zeroing the memory is not correct for types that don't have a zero-
default, but those cannot be detected with just RTTI. Zeroing the
memory is usually still better then leaving it as is.
For the JavaScript and VM backends, the zeroMem call is excluded
from compilation. Using invokeNewSeq and extendSeq is already
not possible on these backends.
Summary
New seq slots are now zeroed when expanding the seq via
invokeNewSeq
orextendSeq
, making the behaviour consistent withsetLen
andnewSeq
, and also fixing crashes withmarshal
caused by the uninitialized memory.Details
Zeroing the memory is not correct for types that don't have a zero- default, but those cannot be detected with just RTTI. Zeroing the memory is usually still better then leaving it as is.
For the JavaScript and VM backends, the
zeroMem
call is excluded from compilation. UsinginvokeNewSeq
andextendSeq
is already not possible on these backends.Fixes https://github.com/nim-works/nimskull/issues/1462