merges r29318 from trunk into ruby_1_9_2.

--
* vm_insnhelper.c (vm_cref_push): no outer cref is needed for proc
  from method.  Bug #3786, Bug #3860, [ruby-core:32501]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@29565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
yugui 2010-10-23 09:37:01 +00:00
parent 03144f6df0
commit 4f7232fd2e
4 changed files with 32 additions and 10 deletions

View file

@ -1,3 +1,8 @@
Thu Sep 23 09:01:28 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_cref_push): no outer cref is needed for proc
from method. Bug #3786, Bug #3860, [ruby-core:32501]
Wed Oct 6 11:52:12 2010 Nobuyoshi Nakada <nobu@ruby-lang.org> Wed Oct 6 11:52:12 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (fptr_finalize): write_mutex might have been destroyed * io.c (fptr_finalize): write_mutex might have been destroyed

View file

@ -415,4 +415,19 @@ class TestEval < Test::Unit::TestCase
assert_raise(ArgumentError) {eval("__ENCODING__".encode("utf-32be"))} assert_raise(ArgumentError) {eval("__ENCODING__".encode("utf-32be"))}
assert_raise(ArgumentError) {eval("__ENCODING__".encode("utf-32le"))} assert_raise(ArgumentError) {eval("__ENCODING__".encode("utf-32le"))}
end end
def test_instance_eval_method_proc
bug3860 = Class.new do
def initialize(a);
@a=a
end
def get(*args)
@a
end
end
foo = bug3860.new 1
foo_pr = foo.method(:get).to_proc
result = foo.instance_eval(&foo_pr)
assert_equal(1, result, 'Bug #3786, Bug #3860, [ruby-core:32501]')
end
end end

View file

@ -1,5 +1,5 @@
#define RUBY_VERSION "1.9.2" #define RUBY_VERSION "1.9.2"
#define RUBY_PATCHLEVEL 18 #define RUBY_PATCHLEVEL 19
#define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 1 #define RUBY_VERSION_TEENY 1

View file

@ -1053,21 +1053,23 @@ vm_getspecial(rb_thread_t *th, VALUE *lfp, VALUE key, rb_num_t type)
} }
static NODE * static NODE *
vm_get_cref(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp) vm_get_cref0(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp)
{ {
NODE *cref = 0;
while (1) { while (1) {
if (lfp == dfp) { if (lfp == dfp) {
cref = iseq->cref_stack; return iseq->cref_stack;
break;
} }
else if (dfp[-1] != Qnil) { else if (dfp[-1] != Qnil) {
cref = (NODE *)dfp[-1]; return (NODE *)dfp[-1];
break;
} }
dfp = GET_PREV_DFP(dfp); dfp = GET_PREV_DFP(dfp);
} }
}
static NODE *
vm_get_cref(const rb_iseq_t *iseq, const VALUE *lfp, const VALUE *dfp)
{
NODE *cref = vm_get_cref0(iseq, lfp, dfp);
if (cref == 0) { if (cref == 0) {
rb_bug("vm_get_cref: unreachable"); rb_bug("vm_get_cref: unreachable");
@ -1084,10 +1086,10 @@ vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr)
cref->nd_visi = noex; cref->nd_visi = noex;
if (blockptr) { if (blockptr) {
cref->nd_next = vm_get_cref(blockptr->iseq, blockptr->lfp, blockptr->dfp); cref->nd_next = vm_get_cref0(blockptr->iseq, blockptr->lfp, blockptr->dfp);
} }
else if (cfp) { else if (cfp) {
cref->nd_next = vm_get_cref(cfp->iseq, cfp->lfp, cfp->dfp); cref->nd_next = vm_get_cref0(cfp->iseq, cfp->lfp, cfp->dfp);
} }
return cref; return cref;