diff --git proc.c proc.c index 850de22..a3addcc 100644 --- proc.c +++ proc.c @@ -2740,7 +2740,8 @@ curry(VALUE dummy, VALUE args, int argc, VALUE *argv, VALUE passed_proc) return arity; } else { - return rb_proc_call_with_block(proc, check_argc(RARRAY_LEN(passed)), RARRAY_CONST_PTR(passed), passed_proc); + VALUE corrected_passed_proc = (SYMBOL_P(passed_proc)) ? sym_proc_new(rb_cProc, passed_proc) : passed_proc; + return rb_proc_call_with_block(proc, check_argc(RARRAY_LEN(passed)), RARRAY_CONST_PTR(passed), corrected_passed_proc); } } diff --git test/ruby/test_proc.rb test/ruby/test_proc.rb index 58a2b17..f67e332 100644 --- test/ruby/test_proc.rb +++ test/ruby/test_proc.rb @@ -283,6 +283,18 @@ def test_curry assert_equal(9, b) end + def test_curry_with_block + b = proc { true }.curry + assert(b.call, "without block") + assert(b.call { |o| o.to_s }, "with block") + assert(b.call(&:to_s), "with sym block") + + b = lambda { true }.curry + assert(b.call, "without block") + assert(b.call { |o| o.to_s }, "with block") + assert(b.call(&:to_s), "with sym block") + end + def test_lambda? l = proc {} assert_equal(false, l.lambda?)