facets
facets copied to clipboard
Enumerable::Argumentable broken for .min and .max :bug:
The implementation of Enumerable::Argumentable is broken for methods with an .arity of -1 such as .min and .max
In both cases the method has a variable number of arguments which makes it .arity = -1. Given the way Argumentable works for arity -1 the method always passes the single argument to the min method, and passes nothing to the each resulting it taking the X smallest values of the given and unchanged array
The offending code is here
These are the affected methods
# 2.2.0
Enumerable.instance_methods.
map{|m| [m, Enumerable.instance_method(m).arity]}.
select{|e| e.last < 0}.
map(&:first)
# => [:to_a, :entries, :to_h, :count, :find, :detect, :find_index, :inject, :reduce, :first, :min, :max, :min_by, :max_by, :each_with_index, :reverse_each, :each_entry, :zip, :cycle, :chunk, :slice_before, :slice_after, :to_set]
# That's 23 methods out of 52 total.