[CLJS-426] subvec function not behaving consitently with invalid subranges Created: 22/Nov/12 Updated: 23/Nov/12 Resolved: 23/Nov/12 |
|
| Status: | Resolved |
| 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: |
|
| 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 |