diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-06 00:31:55 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-07-06 00:31:55 +0000 |
| commit | 9c4668aecef4e5f656d5b5d980b14d39a58282d7 (patch) | |
| tree | 7cce588ffd1b64372f62b11644fd934210cc7a43 | |
| parent | d05f5ed5beedb56badb2ba7baed6e07b903e9d7c (diff) | |
| download | ruby-9c4668aecef4e5f656d5b5d980b14d39a58282d7.tar.gz ruby-9c4668aecef4e5f656d5b5d980b14d39a58282d7.tar.xz ruby-9c4668aecef4e5f656d5b5d980b14d39a58282d7.zip | |
* proc.c (make_curry_proc): should propagate lambda-ness.
[ruby-core:24127]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@23970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | proc.c | 12 | ||||
| -rw-r--r-- | test/ruby/test_proc.rb | 7 |
3 files changed, 21 insertions, 3 deletions
@@ -1,4 +1,7 @@ -Mon Jul 6 09:23:28 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> +Mon Jul 6 09:31:50 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * proc.c (make_curry_proc): should propagate lambda-ness. + [ruby-core:24127] * proc.c (proc_hash): use long. @@ -1765,9 +1765,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 @@ -1781,7 +1789,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 e557f185f..5a00fdb12 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -181,6 +181,13 @@ class TestProc < Test::Unit::TestCase 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 |
