From bd9b986c1bd2890d90a1e108db9df69304dec7fd Mon Sep 17 00:00:00 2001 From: yugui Date: Mon, 13 Jul 2009 06:12:36 +0000 Subject: merges r23970 from trunk into ruby_1_9_1. -- * proc.c (make_curry_proc): should propagate lambda-ness. [ruby-core:24127] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@24069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ proc.c | 12 ++++++++++-- test/ruby/test_proc.rb | 12 ++++++++++++ version.h | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 24fed7847..e61327dec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Jul 6 09:31:50 2009 Nobuyoshi Nakada + + * proc.c (make_curry_proc): should propagate lambda-ness. + [ruby-core:24127] + Sun Jul 5 14:04:36 2009 Nobuyoshi Nakada * thread.c (rb_threadptr_exec_event_hooks): new function to diff --git a/proc.c b/proc.c index 300e18d90..ed44512ca 100644 --- a/proc.c +++ b/proc.c @@ -1694,9 +1694,17 @@ static VALUE make_curry_proc(VALUE proc, VALUE passed, VALUE arity) { VALUE args = rb_ary_new3(3, proc, passed, arity); + rb_proc_t *procp; + int is_lambda; + + GetProcPtr(proc, procp); + is_lambda = procp->is_lambda; rb_ary_freeze(passed); rb_ary_freeze(args); - return rb_proc_new(curry, args); + proc = rb_proc_new(curry, args); + GetProcPtr(proc, procp); + procp->is_lambda = is_lambda; + return proc; } static VALUE @@ -1710,7 +1718,7 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc) passed = rb_ary_plus(passed, rb_ary_new4(argc, argv)); rb_ary_freeze(passed); - if(RARRAY_LEN(passed) < FIX2INT(arity)) { + if (RARRAY_LEN(passed) < FIX2INT(arity)) { if (!NIL_P(passed_proc)) { rb_warn("given block not used"); } diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 89ae569e3..0b43a0385 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -176,6 +176,18 @@ class TestProc < Test::Unit::TestCase b = proc { :foo } assert_equal(:foo, b.curry[]) + + b = lambda {|x, y, &b| b.call(x + y) }.curry + b = b.call(2) { raise } + b = b.call(3) {|x| x + 4 } + assert_equal(9, b) + + l = proc {} + assert_equal(false, l.lambda?) + assert_equal(false, l.curry.lambda?, '[ruby-core:24127]') + l = lambda {} + assert_equal(true, l.lambda?) + assert_equal(true, l.curry.lambda?, '[ruby-core:24127]') end def test_curry_ski_fib diff --git a/version.h b/version.h index aa15ab449..38be2bf8d 100644 --- a/version.h +++ b/version.h @@ -1,6 +1,6 @@ #define RUBY_VERSION "1.9.1" #define RUBY_RELEASE_DATE "2009-07-12" -#define RUBY_PATCHLEVEL 219 +#define RUBY_PATCHLEVEL 220 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1 -- cgit