summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-09 09:05:18 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-09 09:05:18 +0000
commit7adb8681f015fd958288edd9c5d78484764ec34a (patch)
treeae6f00953f725b9e004d48adbdfd49e13873a30e
parenta563f713984b84305d92b99c547a7e48c33ea2f7 (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_7@23997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--eval.c2
-rw-r--r--gc.c2
-rw-r--r--test/ruby/test_proc.rb10
-rw-r--r--version.h8
5 files changed, 23 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 8ebb356..11185b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Jul 9 17:58:03 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* eval.c (rb_thread_remove): stops timer thread unless other
diff --git a/eval.c b/eval.c
index 8d1c5e3..8ae0d3f 100644
--- a/eval.c
+++ b/eval.c
@@ -8872,7 +8872,7 @@ proc_invoke(proc, args, self, klass)
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 */
diff --git a/gc.c b/gc.c
index a564f0b..da56b9d 100644
--- a/gc.c
+++ b/gc.c
@@ -1356,7 +1356,7 @@ obj_free(obj)
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;
diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb
index 0ddc76a..5436879 100644
--- a/test/ruby/test_proc.rb
+++ b/test/ruby/test_proc.rb
@@ -91,4 +91,14 @@ class TestProc < Test::Unit::TestCase
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
diff --git a/version.h b/version.h
index 5ecd36d..a8167fd 100644
--- a/version.h
+++ b/version.h
@@ -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[];