Skip to content
This repository

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

Closed
yagudaev opened this Issue July 24, 2012 · 2 comments

3 participants

Michael Yagudaev Jeremy Ashkenas Ted Han
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 July 25, 2012
Guangcheng Wei 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 July 27, 2012
Guangcheng Wei 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 August 30, 2012
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.