Issue #5746 has been updated by marcandre (Marc-Andre Lafortune).

Assignee changed from nobu (Nobuyoshi Nakada) to marcandre (Marc-Andre Lafortune)


----------------------------------------
Bug #5746: Proc#curry too strict about lambda's arity.
https://bugs.ruby-lang.org/issues/5746#change-28154

Author: marcandre (Marc-Andre Lafortune)
Status: Assigned
Priority: Normal
Assignee: marcandre (Marc-Andre Lafortune)
Category: core
Target version: 
ruby -v: -


Currently, Proc#curry raises an error when you attempt to curry a lambda with optional (but limited) arguments:

    l = ->(arg = 42) {}
    l.curry(1) # => ArgumentError: wrong number of arguments (1 for 0)

Note that Proc#curry behaves correctly if the Proc was created from a method, even though arguments are treated the same way:

    def Object.foo(arg = 42); end
    m = Object.method(:foo).to_proc
    m.class # => Proc, same as 'l'
    m.lambda? # => true, same as 'l'
    m.curry(1) # => curried proc

Referring to my evaluation method, my proposed fix passes SST:
a) usefulness: way more useful, as it makes it possible to do something that is not currently possible
b) consistency: makes it consistent with equivalent method
c) intuitiveness and d) performance: similar

It is straightforward (but not obvious), as it passes NIT (but not ODT).

This bug is a consequence of the redmine issue 5694; this will be fixed automatically when 5694 is fixed.



-- 
http://bugs.ruby-lang.org/