Issue #5746 has been reported by Marc-Andre Lafortune. ---------------------------------------- Bug #5746: Proc#curry too strict about lambda's arity. http://redmine.ruby-lang.org/issues/5746 Author: Marc-Andre Lafortune Status: Open Priority: Normal Assignee: 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.
on 2011-12-11 18:08
on 2011-12-11 22:07
Hi,
In message "Re: [ruby-core:41594] [ruby-trunk - Bug #5746][Open]
Proc#curry too strict about lambda's arity."
on Mon, 12 Dec 2011 02:08:08 +0900, Marc-Andre Lafortune
<ruby-core@marc-andre.ca> writes:
|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)
In my opinion, #curry should not rely on #arity at all. Even after
proposed fix, it accepts l.curry(3) which is wrong. It should use
more reliable information such as #parameters.
matz.
on 2011-12-12 01:36
Hi, On Sun, Dec 11, 2011 at 4:06 PM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote: > In my opinion, #curry should not rely on #arity at all. Even after > proposed fix, it accepts l.curry(3) which is wrong. I'm glad you agree that this is also another bug (although much less severe... it simply fails the fail-early principle, but at least it doesn't fail for no good reason, like this bug). > It should use > more reliable information such as #parameters. Or my suggested arity_max. I had already prepared a bug report this morning, which I'll post now, and I'll post a proposed fix when I get a chance...
on 2012-04-24 13:20
Issue #5746 has been updated by mame (Yusuke Endoh). Assignee changed from mame (Yusuke Endoh) to matz (Yukihiro Matsumoto) This issue is blocked by #5694 which is assigned to matz. So I'm assigning this to matz. -- Yusuke Endoh <mame@tsg.ne.jp> ---------------------------------------- Bug #5746: Proc#curry too strict about lambda's arity. https://bugs.ruby-lang.org/issues/5746#change-26158 Author: marcandre (Marc-Andre Lafortune) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) 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.
on 2012-07-14 08:51
Issue #5746 has been updated by ko1 (Koichi Sasada). Assignee changed from matz (Yukihiro Matsumoto) to nobu (Nobuyoshi Nakada) ---------------------------------------- Bug #5746: Proc#curry too strict about lambda's arity. https://bugs.ruby-lang.org/issues/5746#change-28043 Author: marcandre (Marc-Andre Lafortune) Status: Assigned Priority: Normal Assignee: nobu (Nobuyoshi Nakada) 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.
on 2012-07-16 17:41
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.
on 2013-01-25 06:54
Issue #5746 has been updated by marcandre (Marc-Andre Lafortune). Status changed from Assigned to Closed This was fixed when #5694 was resolved. ---------------------------------------- Bug #5746: Proc#curry too strict about lambda's arity. https://bugs.ruby-lang.org/issues/5746#change-35621 Author: marcandre (Marc-Andre Lafortune) Status: Closed 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.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.