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

fixes #22856; enables -d:nimStrictDelete #22858

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions lib/system.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
##
Expand All @@ -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")
Expand Down
Loading