ClojureScript

subvec function not behaving consitently with invalid subranges

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
  • Environment:
    Ubuntu precise 64 bits, Mac OS X Lion
  • 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.

  1. cljs_subvec.patch
    22/Nov/12 5:05 PM
    4 kB
    Roman Gonzalez
  2. cljs_subvec_revised1.patch
    23/Nov/12 3:18 PM
    4 kB
    Roman Gonzalez
  3. cljs_subvec_revised.patch
    23/Nov/12 3:09 PM
    4 kB
    Roman Gonzalez

Activity

Hide
Roman Gonzalez added a comment -

Patch for bug

Show
Roman Gonzalez added a comment - Patch for bug
Hide
David Nolen added a comment -

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

(build-subvec. meta (-assoc v v-pos val) ...
Show
David Nolen added a comment - This mostly looks good but there is a typo in the patch:
(build-subvec. meta (-assoc v v-pos val) ...
Hide
Roman Gonzalez added a comment -

Revised patch, removing small typo

Show
Roman Gonzalez added a comment - Revised patch, removing small typo
Hide
Roman Gonzalez added a comment -

Removing useless ^:mutable meta on function parameter

Show
Roman Gonzalez added a comment - Removing useless ^:mutable meta on function parameter

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: