nim-works / nimskull

An in development statically typed systems programming language; with sustainability at its core. We, the community of users, maintain it.
https://nim-works.github.io/nimskull/index.html
Other
279 stars 39 forks source link

fix(typeinfo): expanding seq doesn't clear locations #1463

Closed zerbina closed 2 months ago

zerbina commented 2 months ago

Summary

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.

Fixes https://github.com/nim-works/nimskull/issues/1462

saem commented 2 months ago

/merge

github-actions[bot] commented 2 months ago

Merge requested by: @saem

Contents after the first section break of the PR description has been removed and preserved below: