Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warn about destructors with setLenUninit in docs #24345

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/system/seqs_v2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ func setLenUninit*[T](s: var seq[T], newlen: Natural) {.nodestroy.} =
## Sets the length of seq `s` to `newlen`. `T` may be any sequence type.
## New slots will not be initialized.
##
## .. warning:: Assigning to the uninitialized slots can generate
## destructor calls. If the slots have garbage data, they can still
## be interpreted as well-formed, potentially causing crashes.
## To prevent this, destructor injections should be disabled in the
## context, currently possible via the [nodestroy pragma](destructors.html#nodestroy-pragma).
##
## If the current length is greater than the new length,
## `s` will be truncated.
## ```nim
Expand Down
Loading