<< Back to previous view

[CLJS-426] subvec function not behaving consitently with invalid subranges Created: 22/Nov/12  Updated: 27/Jul/13  Resolved: 23/Nov/12

Status: Closed
Project: ClojureScript
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Defect Priority: Major
Reporter: Roman Gonzalez Assignee: Unassigned
Resolution: Completed Votes: 0
Labels: bug, patch
Environment:

Ubuntu precise 64 bits, Mac OS X Lion


Attachments: Text File cljs_subvec.patch     Text File cljs_subvec_revised1.patch     Text File cljs_subvec_revised.patch    
Patch: Code and Test

 Description   

When using the subvec function with a as a parameter vector and a range that is not in the original vector, the function returns a value:

(subvec [1 2 3] 0 4) => [1 2 3 nil]

However, when using with seqs, it works as it supposed to:

(subvec (range 3) 0 4) => ERROR: Index out of bounds

This is because the validation of ranges is not happening at build time of the subvec type, this bug contains a patch that adds a new private `build-subvec` function into cljs.core.



 Comments   
Comment by Roman Gonzalez [ 22/Nov/12 5:05 PM ]

Patch for bug

Comment by David Nolen [ 23/Nov/12 2:51 PM ]

This mostly looks good but there is a typo in the patch:

(build-subvec. meta (-assoc v v-pos val) ...
Comment by Roman Gonzalez [ 23/Nov/12 3:09 PM ]

Revised patch, removing small typo

Comment by Roman Gonzalez [ 23/Nov/12 3:18 PM ]

Removing useless ^:mutable meta on function parameter

Comment by David Nolen [ 23/Nov/12 3:25 PM ]

fixed, http://github.com/clojure/clojurescript/commit/ee25599abb214074cbeefe37b399038d70c6ab89

Generated at Sat Dec 20 09:53:05 CST 2014 using JIRA 4.4#649-r158309.