diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-08 03:06:13 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-08 03:06:13 +0000 |
commit | d928280cb6644d2d899aadf7bfc8cf4e1b5e2997 (patch) | |
tree | c366adbd42bc4330b4009a5da44936e981c10c3d /eval.c | |
parent | db051011d68950cd1261f91e724513282d419d9e (diff) | |
download | ruby-d928280cb6644d2d899aadf7bfc8cf4e1b5e2997.tar.gz |
* 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
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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); |