ruby-changes:12303
From: shyouhei <ko1@a...>
Date: Thu, 9 Jul 2009 18:05:35 +0900 (JST)
Subject: [ruby-changes:12303] Ruby:r23997 (ruby_1_8_7): merge revision(s) 23257:
shyouhei 2009-07-09 18:05:18 +0900 (Thu, 09 Jul 2009) New Revision: 23997 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=23997 Log: merge revision(s) 23257: * eval.c (proc_invoke): shares dmethod scope local variables. a patch from coderrr at [ruby-core:23050] * gc.c (obj_free): do not free cloned scope local variables. Modified files: branches/ruby_1_8_7/ChangeLog branches/ruby_1_8_7/eval.c branches/ruby_1_8_7/gc.c branches/ruby_1_8_7/test/ruby/test_proc.rb branches/ruby_1_8_7/version.h Index: ruby_1_8_7/ChangeLog =================================================================== --- ruby_1_8_7/ChangeLog (revision 23996) +++ ruby_1_8_7/ChangeLog (revision 23997) @@ -1,3 +1,10 @@ +Thu Jul 9 17:58:03 2009 Nobuyoshi Nakada <nobu@r...> + + * eval.c (proc_invoke): shares dmethod scope local variables. + a patch from coderrr at [ruby-core:23050] + + * gc.c (obj_free): do not free cloned scope local variables. + Wed Jul 8 19:28:03 2009 Nobuyoshi Nakada <nobu@r...> * eval.c (rb_thread_remove): stops timer thread unless other Index: ruby_1_8_7/version.h =================================================================== --- ruby_1_8_7/version.h (revision 23996) +++ ruby_1_8_7/version.h (revision 23997) @@ -1,15 +1,15 @@ #define RUBY_VERSION "1.8.7" -#define RUBY_RELEASE_DATE "2009-07-08" +#define RUBY_RELEASE_DATE "2009-07-09" #define RUBY_VERSION_CODE 187 -#define RUBY_RELEASE_CODE 20090708 -#define RUBY_PATCHLEVEL 180 +#define RUBY_RELEASE_CODE 20090709 +#define RUBY_PATCHLEVEL 181 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 8 #define RUBY_VERSION_TEENY 7 #define RUBY_RELEASE_YEAR 2009 #define RUBY_RELEASE_MONTH 7 -#define RUBY_RELEASE_DAY 8 +#define RUBY_RELEASE_DAY 9 #ifdef RUBY_EXTERN RUBY_EXTERN const char ruby_version[]; Index: ruby_1_8_7/test/ruby/test_proc.rb =================================================================== --- ruby_1_8_7/test/ruby/test_proc.rb (revision 23996) +++ ruby_1_8_7/test/ruby/test_proc.rb (revision 23997) @@ -91,4 +91,14 @@ assert_equal(10, Proc.new{|&b| b.call(10)}.call {|x| x}) assert_equal(12, Proc.new{|a,&b| b.call(a)}.call(12) {|x| x}) end + + def test_define_method_scope + a = 1 + c = Class.new + c.send(:define_method, :x) do |*| + lambda {a = 2}.call + end + c.new.x(nil) + assert_equal(2, a, '[ruby-core:23050]') + end end Index: ruby_1_8_7/eval.c =================================================================== --- ruby_1_8_7/eval.c (revision 23996) +++ ruby_1_8_7/eval.c (revision 23997) @@ -8872,7 +8872,7 @@ OBJSETUP(scope, tmp, T_SCOPE); scope->local_tbl = _block.scope->local_tbl; scope->local_vars = _block.scope->local_vars; - scope->flags |= SCOPE_CLONE; + scope->flags |= SCOPE_CLONE | (_block.scope->flags & SCOPE_MALLOC); _block.scope = scope; } /* modify current frame */ Index: ruby_1_8_7/gc.c =================================================================== --- ruby_1_8_7/gc.c (revision 23996) +++ ruby_1_8_7/gc.c (revision 23997) @@ -1356,7 +1356,7 @@ VALUE *vars = RANY(obj)->as.scope.local_vars-1; if (!(RANY(obj)->as.scope.flags & SCOPE_CLONE) && vars[0] == 0) RUBY_CRITICAL(free(RANY(obj)->as.scope.local_tbl)); - if (RANY(obj)->as.scope.flags & SCOPE_MALLOC) + if ((RANY(obj)->as.scope.flags & (SCOPE_MALLOC|SCOPE_CLONE)) == SCOPE_MALLOC) RUBY_CRITICAL(free(vars)); } break; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/