From 687958723aa30d5e68c3ba8769217a78e1f38fd3 Mon Sep 17 00:00:00 2001 From: metagn Date: Tue, 22 Oct 2024 17:02:53 +0300 Subject: [PATCH] warn about destructors with `setLenUninit` in docs --- lib/system/seqs_v2.nim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/system/seqs_v2.nim b/lib/system/seqs_v2.nim index 572e77408f43..c41bfe482bef 100644 --- a/lib/system/seqs_v2.nim +++ b/lib/system/seqs_v2.nim @@ -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