-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
delete(seq, index)
with invalid index deletes an element instead of raising
#16544
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
Comments
I hit the bug too, more examples: var a: seq[int] = @[0]
a.delete(999999999999) var a: seq[int] = @[0]
discard a.pop()
a.delete(999999999999) var a: seq[int] = @[0]
discard a.pop()
a.insert(42, 0)
a.delete(999999999999)
|
What do you expect See also |
well, I argue in #16492 that first and foremost, all these operations would ideally present a logically consistent picture, both native types, library types and at compile time - in fact, the most important thing is that they are consistent with each other - ie when one is defined in a particular way, the others follow. Generally, I probably have a slight preference for being lenient with ranges / slices (towards python, but also C++ allows some leniency in these kinds of operations), ie simply return the overlapping part, but one could argue for strictness I guess - there's already lots of |
Just stumbled across this too. |
Is the general consensus that let xs = @[0,1]
xs.delete(2)
# Error: unhandled exception: index 2 not in 0 .. 1 [IndexDefect] |
Can confirm, yes. |
Uh oh!
There was an error while loading. Please reload this page.
Example
Current Output
@[1, 2]
Expected Output
raise
IndexError
viaraiseIndexError2
Additional Information
devel 1.5.1 505d043
a fix should include a comprehensive test
note that
RangeDefect
is raised if passingi
== 0 with x.len == 0note that
del
correctly raises:Error: unhandled exception: index 6 not in 0 .. 2 [IndexDefect]
The text was updated successfully, but these errors were encountered: