diff --git a/ChangeLog b/ChangeLog index dba4754514..558a19b9cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Tue Aug 04 15:30:04 2015 Koichi Sasada + + * proc.c (rb_block_clear_env_self): clear by Qfalse intead of Qnil. + [Bug #11409] + + * test/ruby/test_eval.rb: add tests for this issue, + written by @0x0dea. + https://github.com/ruby/ruby/pull/988 + Tue Aug 4 12:12:14 2015 Eric Wong * variable.c: wrap long lines diff --git a/proc.c b/proc.c index 2eb46ad5d2..4b67c69755 100644 --- a/proc.c +++ b/proc.c @@ -670,7 +670,7 @@ rb_block_clear_env_self(VALUE proc) rb_env_t *env; GetProcPtr(proc, po); GetEnvPtr(rb_vm_proc_envval(po), env); - env->env[0] = Qnil; + env->env[0] = Qfalse; return proc; } diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb index 9d8db3017b..02dbb9b379 100644 --- a/test/ruby/test_eval.rb +++ b/test/ruby/test_eval.rb @@ -126,6 +126,10 @@ class TestEval < Test::Unit::TestCase } end + def test_module_eval_block_symbol + assert_equal "Math", Math.module_eval(&:to_s) + end + def forall_TYPE objects = [Object.new, [], nil, true, false] # TODO: check objects.each do |obj| @@ -199,6 +203,12 @@ class TestEval < Test::Unit::TestCase assert_equal self, pr.call end + def test_instance_eval_block_symbol + forall_TYPE do |o| + assert_equal o.to_s, o.instance_eval(&:to_s) + end + end + def test_instance_eval_cvar [Object.new, [], 7, :sym, true, false, nil].each do |obj| assert_equal(13, obj.instance_eval("@@cvar"))