ruby-changes:12278
From: nobu <ko1@a...>
Date: Mon, 6 Jul 2009 09:32:15 +0900 (JST)
Subject: [ruby-changes:12278] Ruby:r23970 (trunk): * proc.c (make_curry_proc): should propagate lambda-ness.
nobu 2009-07-06 09:31:55 +0900 (Mon, 06 Jul 2009) New Revision: 23970 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23970 Log: * proc.c (make_curry_proc): should propagate lambda-ness. [ruby-core:24127] Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_proc.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 23969) +++ ChangeLog (revision 23970) @@ -1,5 +1,8 @@ -Mon Jul 6 09:23:28 2009 Nobuyoshi Nakada <nobu@r...> +Mon Jul 6 09:31:50 2009 Nobuyoshi Nakada <nobu@r...> + * proc.c (make_curry_proc): should propagate lambda-ness. + [ruby-core:24127] + * proc.c (proc_hash): use long. Mon Jul 6 09:06:49 2009 Yukihiro Matsumoto <matz@r...> Index: proc.c =================================================================== --- proc.c (revision 23969) +++ proc.c (revision 23970) @@ -1765,9 +1765,17 @@ 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 @@ -1781,7 +1789,7 @@ 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"); } Index: test/ruby/test_proc.rb =================================================================== --- test/ruby/test_proc.rb (revision 23969) +++ test/ruby/test_proc.rb (revision 23970) @@ -181,6 +181,13 @@ 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/