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
275 stars 39 forks source link

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

Closed zerbina closed 1 week ago

zerbina commented 1 week 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 1 week ago

/merge

github-actions[bot] commented 1 week ago

Merge requested by: @saem

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