Clojure

Vectors returned by subvec allow access at negative indices

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.5
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

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/v1
user=> (def v2 (subvec v1 50 52))
#'user/v2
user=> (v2 3)
IndexOutOfBoundsException clojure.lang.APersistentVector$SubVector.nth (APersistentVector.java:526)
user=> (v2 -48)
2

Activity

Hide
Andy Fingerhut added a comment -

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.

Show
Andy Fingerhut added a comment - 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.
Hide
Alan Dipert added a comment -

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

Show
Alan Dipert added a comment - I checked this out and it looks good to me, thank you.
Hide
Andy Fingerhut added a comment -

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.

Show
Andy Fingerhut added a comment - 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.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: