From ed57f299b243842e4e874189771d93340aaadddc Mon Sep 17 00:00:00 2001 From: shugo Date: Wed, 16 Dec 2015 10:35:34 +0000 Subject: [PATCH] * vm.c (vm_make_proc_from_block): should convert a Symbol to a Proc. [ruby-core:72083] [Bug #11811] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ test/ruby/test_lazy_enumerator.rb | 7 +++++++ vm.c | 4 ++++ 3 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 670ad280fd..920bbda87c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Dec 16 19:30:56 2015 Shugo Maeda + + * vm.c (vm_make_proc_from_block): should convert a Symbol to a Proc. + [ruby-core:72083] [Bug #11811] + Wed Dec 16 16:17:34 2015 Eric Wong * test/ruby/test_io.rb: fix spelling errors diff --git a/test/ruby/test_lazy_enumerator.rb b/test/ruby/test_lazy_enumerator.rb index 29c6b3e855..5feddd5bde 100644 --- a/test/ruby/test_lazy_enumerator.rb +++ b/test/ruby/test_lazy_enumerator.rb @@ -532,4 +532,11 @@ EOS assert_warning("") {le.drop(1).force} assert_warning("") {le.drop_while{false}.force} end + + def test_symbol_chain + assert_equal(["1", "3"], [1, 2, 3].lazy.reject(&:even?).map(&:to_s).force) + assert_raise(NoMethodError) do + [1, 2, 3].lazy.map(&:undefined).map(&:to_s).force + end + end end diff --git a/vm.c b/vm.c index 087cba7250..a03e068780 100644 --- a/vm.c +++ b/vm.c @@ -567,6 +567,10 @@ vm_make_proc_from_block(rb_thread_t *th, rb_block_t *block, VALUE *procptr) *procptr = block->proc = rb_vm_make_proc(th, block, rb_cProc); return TRUE; } + else if (SYMBOL_P(block->proc)) { + *procptr = rb_sym_to_proc(block->proc); + return TRUE; + } else { *procptr = block->proc; return FALSE;