ruby-changes:39399
From: ko1 <ko1@a...>
Date: Tue, 4 Aug 2015 15:36:10 +0900 (JST)
Subject: [ruby-changes:39399] ko1:r51480 (trunk): * proc.c (rb_block_clear_env_self): clear by Qfalse intead of Qnil.
ko1 2015-08-04 15:35:31 +0900 (Tue, 04 Aug 2015) New Revision: 51480 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51480 Log: * 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 Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_eval.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 51479) +++ ChangeLog (revision 51480) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Aug 04 15:30:04 2015 Koichi Sasada <ko1@a...> + + * 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 <e@8...> * variable.c: wrap long lines Index: proc.c =================================================================== --- proc.c (revision 51479) +++ proc.c (revision 51480) @@ -670,7 +670,7 @@ rb_block_clear_env_self(VALUE proc) https://github.com/ruby/ruby/blob/trunk/proc.c#L670 rb_env_t *env; GetProcPtr(proc, po); GetEnvPtr(rb_vm_proc_envval(po), env); - env->env[0] = Qnil; + env->env[0] = Qfalse; return proc; } Index: test/ruby/test_eval.rb =================================================================== --- test/ruby/test_eval.rb (revision 51479) +++ test/ruby/test_eval.rb (revision 51480) @@ -126,6 +126,10 @@ class TestEval < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L126 } 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 https://github.com/ruby/ruby/blob/trunk/test/ruby/test_eval.rb#L203 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")) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/