From e45b215fdd16f4fefc8f97f2391ef532f10c8f50 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 27 Oct 2014 08:17:26 +0000 Subject: proc.c: fix method proc binding receiver * proc.c (method_proc): the receiver of binding from method should be same as the receiver of the method. [ruby-core:65917] [Bug #10432] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- proc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'proc.c') diff --git a/proc.c b/proc.c index 00512ec49c..a4b8c82a25 100644 --- a/proc.c +++ b/proc.c @@ -2365,7 +2365,10 @@ static VALUE method_proc(VALUE method) { VALUE procval; + struct METHOD *meth; rb_proc_t *proc; + rb_env_t *env; + /* * class Method * def to_proc @@ -2375,9 +2378,16 @@ method_proc(VALUE method) * end * end */ + TypedData_Get_Struct(method, struct METHOD, &method_data_type, meth); procval = rb_iterate(mlambda, 0, bmcall, method); GetProcPtr(procval, proc); proc->is_from_method = 1; + proc->block.self = meth->recv; + proc->block.klass = meth->defined_class; + GetEnvPtr(proc->envval, env); + env->block.self = meth->recv; + env->block.klass = meth->defined_class; + env->block.iseq = method_get_iseq(meth->me->def); return procval; } -- cgit v1.2.3