From d928280cb6644d2d899aadf7bfc8cf4e1b5e2997 Mon Sep 17 00:00:00 2001 From: shugo Date: Sat, 8 Dec 2012 03:06:13 +0000 Subject: * eval.c (rb_mod_refine): raise an ArgumentError if a given block is of a Proc object. * vm_insnhelper.c (vm_call_method): store refined methods in inline cache to improve performance. It's safe now because blocks cannot be yielded with different refinements in the new specification. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38270 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index e7da8a63e2..934037da91 100644 --- a/eval.c +++ b/eval.c @@ -1196,10 +1196,16 @@ rb_mod_refine(VALUE module, VALUE klass) ID id_refinements, id_activated_refinements, id_refined_class, id_defined_at; VALUE refinements, activated_refinements; + rb_thread_t *th = GET_THREAD(); + rb_block_t *block = rb_vm_control_frame_block_ptr(th->cfp); - if (!rb_block_given_p()) { + if (!block) { rb_raise(rb_eArgError, "no block given"); } + if (block->proc) { + rb_raise(rb_eArgError, + "can't pass a Proc as a block to Module#refine"); + } Check_Type(klass, T_CLASS); CONST_ID(id_refinements, "__refinements__"); refinements = rb_attr_get(module, id_refinements); -- cgit v1.2.3