From af2670f1a445a62c4e14f74eebdd3a30816361ad Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 26 Dec 2016 10:00:36 +0000 Subject: [PATCH] vm_eval.c: Symbol#to_proc and instance_exec * vm_eval.c (yield_under): should evaluate the proc on the first argument. [ruby-core:78839] [Bug #13074] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57194 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_symbol.rb | 6 ++++++ vm_eval.c | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index 4a7ca700c9..42b5106298 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -201,6 +201,12 @@ class TestSymbol < Test::Unit::TestCase end; end + def test_to_proc_instance_exec + bug = '[ruby-core:78839] [Bug #13074] should evaluate on the argument' + assert_equal(2, BasicObject.new.instance_exec(1, &:succ), bug) + assert_equal(3, BasicObject.new.instance_exec(1, 2, &:+), bug) + end + def test_call o = Object.new def o.foo(x, y); x + y; end diff --git a/vm_eval.c b/vm_eval.c index c08a849e59..721ea00700 100644 --- a/vm_eval.c +++ b/vm_eval.c @@ -1591,7 +1591,8 @@ yield_under(VALUE under, VALUE self, int argc, const VALUE *argv) block_handler = vm_proc_to_block_handler(VM_BH_TO_PROC(block_handler)); goto again; case block_handler_type_symbol: - return rb_sym_proc_call(SYM2ID(VM_BH_TO_SYMBOL(block_handler)), 1, &self, VM_BLOCK_HANDLER_NONE); + return rb_sym_proc_call(SYM2ID(VM_BH_TO_SYMBOL(block_handler)), + argc, argv, VM_BLOCK_HANDLER_NONE); } new_captured.self = self;