Skip to content

Commit

Permalink
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions core/src/main/ruby/jruby/kernel/proc.rb
Original file line number Diff line number Diff line change
@@ -9,9 +9,16 @@ def curry(curried_arity = nil)
end

if arity < -1
is_rest = parameters.find {|(type, _)| type == :rest }
is_rest, opt = false, 0
parameters.each do |arr|
case arr[0]
when :rest then
is_rest = true
when :opt then
opt += 1
end
end
req = -arity - 1
opt = parameters.find_all {|(type, _)| type == :opt }.size
if curried_arity < req || curried_arity > (req + opt) && !is_rest
expected = is_rest ? "#{req}+" : "#{req}..#{req+opt}"
raise ArgumentError, "wrong number of arguments (given %i, expected %s)" % [

0 comments on commit 679bb6e

Please sign in to comment.