summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authormarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-21 00:13:44 +0000
committermarcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-02-21 00:13:44 +0000
commitf12c14d3ef2474631c78d28b45d15db1d2cc668c (patch)
tree4b6deab7ffae8f30c9029bae6b9a96d9d4fd7f78 /proc.c
parent3052f75db499d18a7954766e1178a8d7e06c1867 (diff)
downloadruby-f12c14d3ef2474631c78d28b45d15db1d2cc668c.tar.gz
* proc.c (method_hash, proc_hash): Fix {Unbound}Method#hash
[Bug #6048]. Isolate hash computation for proc * internal.h: Declaration for above * vm_method.c (rb_method_definition_hash): Computation for hash part of a method definition * method.h: Declaration for above * test/ruby/test_method.rb: Test for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/proc.c b/proc.c
index cdbf40e4a4..c2859223c5 100644
--- a/proc.c
+++ b/proc.c
@@ -794,6 +794,15 @@ proc_eq(VALUE self, VALUE other)
return Qfalse;
}
+st_index_t
+rb_hash_proc(st_index_t hash, VALUE prc)
+{
+ const rb_proc_t *proc = (const rb_proc_t *)prc;
+ hash = rb_hash_uint(hash, (st_index_t)proc->block.iseq);
+ hash = rb_hash_uint(hash, (st_index_t)proc->envval);
+ return rb_hash_uint(hash, (st_index_t)proc->block.lfp >> 16);
+}
+
/*
* call-seq:
* prc.hash -> integer
@@ -807,9 +816,8 @@ proc_hash(VALUE self)
st_index_t hash;
rb_proc_t *proc;
GetProcPtr(self, proc);
- hash = rb_hash_start((st_index_t)proc->block.iseq);
- hash = rb_hash_uint(hash, (st_index_t)proc->envval);
- hash = rb_hash_uint(hash, (st_index_t)proc->block.lfp >> 16);
+ hash = rb_hash_start(0);
+ hash = rb_hash_proc(hash, proc);
hash = rb_hash_end(hash);
return LONG2FIX(hash);
}
@@ -1075,7 +1083,7 @@ method_hash(VALUE method)
TypedData_Get_Struct(method, struct METHOD, &method_data_type, m);
hash = rb_hash_start((st_index_t)m->rclass);
hash = rb_hash_uint(hash, (st_index_t)m->recv);
- hash = rb_hash_uint(hash, (st_index_t)m->me->def);
+ hash = rb_hash_method_entry(hash, m->me);
hash = rb_hash_end(hash);
return INT2FIX(hash);