From b40dbc304efe8297d7dbe10d6781c7608a651934 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 25 Dec 2007 02:14:36 +0000 Subject: * vm.c: check frame is FINAL when creating env. [ruby-core:14395] * bootstraptest/test_block.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ bootstraptest/test_block.rb | 40 ++++++++++++++++++++++++++++++++++++++++ vm.c | 7 ++++++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e188f9f920..086a63e706 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Tue Dec 25 11:02:10 2007 Koichi Sasada + + * vm.c: check frame is FINAL when creating env. + [ruby-core:14395] + + * bootstraptest/test_block.rb: add a test for above. + Tue Dec 25 09:12:13 2007 Eric Hodel * lib/rdoc/: Enable RDoc debugging only with $DEBUG_RDOC. diff --git a/bootstraptest/test_block.rb b/bootstraptest/test_block.rb index 3ece21756d..2db149063e 100644 --- a/bootstraptest/test_block.rb +++ b/bootstraptest/test_block.rb @@ -507,3 +507,43 @@ assert_equal "ok", %q{ end foo(&:bar) }, '[ruby-core:14279]' + +assert_normal_exit %q{ + class Controller + def respond_to(&block) + responder = Responder.new + block.call(responder) + responder.respond + end + def test_for_bug + respond_to{|format| + format.js{ + puts "in test" + render{|obj| + puts obj + } + } + } + end + def render(&block) + puts "in render" + end + end + + class Responder + def method_missing(symbol, &block) + puts "enter method_missing" + @response = Proc.new{ + puts 'in method missing' + block.call + } + puts "leave method_missing" + end + def respond + @response.call + end + end + t = Controller.new + t.test_for_bug +}, '[ruby-core:14395]' + diff --git a/vm.c b/vm.c index 2ef4d79001..0658187406 100644 --- a/vm.c +++ b/vm.c @@ -238,7 +238,7 @@ vm_make_env_each(rb_thread_t *th, rb_control_frame_t *cfp, for (i = 0; i <= local_size; i++) { env->env[i] = envptr[-local_size + i]; #if 0 - dp(env->env[i]); + fprintf(stderr, "%2d ", &envptr[-local_size + i] - th->stack); dp(env->env[i]); if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { /* clear value stack for GC */ envptr[-local_size + i] = 0; @@ -315,6 +315,11 @@ vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp) { VALUE envval; + if (VM_FRAME_FLAG(cfp->flag) == FRAME_MAGIC_FINISH) { + /* for method_missing */ + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); + } + envval = vm_make_env_each(th, cfp, cfp->dfp, cfp->lfp); if (PROCDEBUG) { -- cgit v1.2.3