From 5141b6c8160c758a730541102d086911e37027d9 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:17:31 +0800 Subject: [PATCH 1/2] fixes #22856; enables `-d:nimStrictDelete` fixes #22856 `-d:nimStrictDelete` is introduced in 1.6.0, which promised to be enabled in the coming versions. To keep backwards incompatibilities, it also extends the feature of `-d:nimAuditDelete`, which now mimics the old behaviors. --- lib/system.nim | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/system.nim b/lib/system.nim index 8d1cda86815e3..59f28a01ff625 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -1986,10 +1986,6 @@ proc delete*[T](x: var seq[T], i: Natural) {.noSideEffect, auditDelete.} = ## ## This is an `O(n)` operation. ## - ## .. note:: With `-d:nimStrictDelete`, an index error is produced when the index passed - ## to it was out of bounds. `-d:nimStrictDelete` will become the default - ## in upcoming versions. - ## ## See also: ## * `del <#del,seq[T],Natural>`_ for O(1) operation ## @@ -1998,7 +1994,7 @@ proc delete*[T](x: var seq[T], i: Natural) {.noSideEffect, auditDelete.} = s.delete(2) doAssert s == @[1, 2, 4, 5] - when defined(nimStrictDelete): + when not defined(nimAuditDelete): if i > high(x): # xxx this should call `raiseIndexError2(i, high(x))` after some refactoring raise (ref IndexDefect)(msg: "index out of bounds: '" & $i & "' < '" & $x.len & "' failed") From 37ede4ec2b8d65e9723b28eb3bbe044870292dd6 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:18:25 +0800 Subject: [PATCH 2/2] adds a changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index 72d0a2a2dd7a3..58efde163f1e3 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,7 @@ ## Changes affecting backward compatibility +- `-d:nimStrictDelete` becomes the default. An index error is produced when the index passed to `system.delete` was out of bounds. Use `-d:nimAuditDelete` to mimic the old behavior for backwards compatibility. ## Standard library additions and changes