<< Back to previous view

[CLJ-962] Vectors returned by subvec allow access at negative indices Created: 29/Mar/12  Updated: 18/May/12  Resolved: 18/May/12

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Release 1.5

Type: Defect Priority: Minor
Reporter: Andy Fingerhut Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: None

Attachments: Text File clj-962-subvec-nth-throws-on-negative-index-patch2.txt    
Patch: Code and Test
Approval: Ok


Google group thread: https://mail.google.com/mail/?shva=1#label/clojure/1365e058eaf0d5fa

Vectors returned by subvec correctly disallow access to elements after their end, but not before their beginning.

Clojure 1.3.0
user=> (def v1 (vec (range 100)))
user=> (def v2 (subvec v1 50 52))
user=> (v2 3)
IndexOutOfBoundsException clojure.lang.APersistentVector$SubVector.nth (APersistentVector.java:526)
user=> (v2 -48)

Comment by Andy Fingerhut [ 29/Mar/12 10:12 AM ]

One-line simple fix. clj-962-subvec-nth-throws-on-negative-index-patch1.txt dated March 29, 2012 applies, builds, and tests cleanly on latest master. Includes a few new tests that exhibit the problem. One author has signed CA.

Comment by Alan Dipert [ 20/Apr/12 1:52 PM ]

I checked this out and it looks good to me, thank you.

Comment by Andy Fingerhut [ 10/May/12 6:29 PM ]

clj-962-subvec-nth-throws-on-negative-index-patch2.txt dated May 10, 2012 is identical to previous patch clj-962-subvec-nth-throws-on-negative-index-patch1.txt dated Mar 29, 2012, except previous one failed to apply cleanly to latest master because of some lines of context changing in the source code.

Generated at Wed Jan 17 22:26:14 CST 2018 using JIRA 4.4#649-r158309.