jashkenas / underscore

JavaScript's utility _ belt
https://underscorejs.org
MIT License
27.33k stars 5.53k forks source link

Double chaining leads to a stack overflow #2853

Open jgonggrijp opened 4 years ago

jgonggrijp commented 4 years ago

The following expression is useless, since you'd expect the second chain call to just return a new wrapper of the same value:

_.chain([1]).chain()

but rather than behaving like a no-op, it results in a stack overflow. Credits to @reubenrybnik for pointing this out in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/45201#issuecomment-637696652. This minor pitfall might have been introduced with #1691.

I'm hesitant to give this a "bug" label as it is rather non-urgent, but technically it's a bug. Documenting in an issue ticket for reference.