Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 164cdedfb6ad
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f7d1444d8678
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Feb 14, 2017

  1. Fix last curry spec failing and then some...

    - arity 0 needs explicit check for required only path
    - arity is insufficient for optional+rest signatures.  Use parameters
      to get the extra info we need
    - update the exception to match Ruby 2.3 argument error exception format.
    enebo committed Feb 14, 2017
    Copy the full SHA
    85b367e View commit details
  2. Fix last curry spec failing and then some...

        - arity 0 needs explicit check for required only path
        - arity is insufficient for optional+rest signatures.  Use parameters
          to get the extra info we need
        - update the exception to match Ruby 2.3 argument error exception format.
    enebo committed Feb 14, 2017
    Copy the full SHA
    f7d1444 View commit details
Showing with 13 additions and 8 deletions.
  1. +13 −7 core/src/main/ruby/jruby/kernel/proc.rb
  2. +0 −1 spec/tags/ruby/core/proc/curry_tags.txt
20 changes: 13 additions & 7 deletions core/src/main/ruby/jruby/kernel/proc.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
class Proc
def curry(curried_arity = nil)
if lambda? && curried_arity
if arity > 0 && curried_arity != arity
raise ArgumentError, "wrong number of arguments (%i for %i)" % [
if arity >= 0 && curried_arity != arity
raise ArgumentError, "wrong number of arguments (given %i, expected %i)" % [
curried_arity,
arity
]
end

if arity < 0 && curried_arity < (-arity - 1)
raise ArgumentError, "wrong number of arguments (%i for %i)" % [
curried_arity,
-arity - 1
]
if arity < -1
is_rest = parameters.find {|(type, _)| type == :rest }
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)" % [
curried_arity,
expected
]
end
end
end

1 change: 0 additions & 1 deletion spec/tags/ruby/core/proc/curry_tags.txt

This file was deleted.