Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bug with _.range() with a bad start point #683

Closed
yagudaev opened this Issue · 2 comments

3 participants

Michael Yagudaev Ted Han Jeremy Ashkenas
Michael Yagudaev

If you call _.range() or _.range("", 2000) or _.range(null, null) or _.range(null, 2000), underscore will return an very long array (almost infinite, but probably just reaches the limit of array size in javascript or on the machine) as such ["", "1", "11", "111", "1111", "1111", "11111"...].

This looks like a classic case of both concatenation of a string instead of addition ('' + 1) and an infinite loop.

Guangcheng Wei twksos referenced this issue from a commit in twksos/underscore
Guangcheng Wei twksos Fix #683 - return -1 for range() if start is not a number. 70aa80d
Ted Han
Collaborator

btw, you might want to check out #634

Guangcheng Wei twksos referenced this issue from a commit in twksos/underscore
Guangcheng Wei twksos Fix #683 - raise error for range() if start is not a number. 0eb6c04
Jeremy Ashkenas
Owner

Yep -- that's why you need to call range with numbers. We don't want to make this "work".

Jeremy Ashkenas jashkenas closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.