diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-20 00:17:25 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-11-20 00:17:25 +0000 |
commit | c267d24ef0b4955ee5d0538707ed47d1b6278699 (patch) | |
tree | 7cc4faa9287f8400cfec82f20e1900def66a705b /eval.c | |
parent | 895b44dcf6d94e58f3daaf78d58453e2735ee827 (diff) | |
download | ruby-c267d24ef0b4955ee5d0538707ed47d1b6278699.tar.gz |
* vm.c (rb_vm_cref_replace_with_duplicated_cref): added.
CREFs should not be shared by methods between `using'.
[Bug #11247]
* vm_insnhelper.c (vm_cref_replace_with_duplicated_cref): ditto.
* vm.c (vm_cref_dup): should copy refinements correctly.
* eval.c: use rb_vm_cref_replace_with_duplicated_cref().
* eval_intern.h: add a decl. of
rb_vm_cref_replace_with_duplicated_cref().
* vm_eval.c (eval_string_with_cref): do not need to pass
scope's CREF because VM can find out CREF from stack frames.
* test/ruby/test_refinement.rb: add a test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52677 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 5 |
1 files changed, 2 insertions, 3 deletions
@@ -1284,7 +1284,6 @@ rb_mod_refine(VALUE module, VALUE klass) static VALUE mod_using(VALUE self, VALUE module) { - const rb_cref_t *cref = rb_vm_cref(); rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD()); if (prev_frame_func()) { @@ -1294,7 +1293,7 @@ mod_using(VALUE self, VALUE module) if (prev_cfp && prev_cfp->self != self) { rb_raise(rb_eRuntimeError, "Module#using is not called on self"); } - rb_using_module(cref, module); + rb_using_module(rb_vm_cref_replace_with_duplicated_cref(), module); return self; } @@ -1427,7 +1426,7 @@ top_using(VALUE self, VALUE module) if (CREF_NEXT(cref) || (prev_cfp && rb_vm_frame_method_entry(prev_cfp))) { rb_raise(rb_eRuntimeError, "main.using is permitted only at toplevel"); } - rb_using_module(cref, module); + rb_using_module(rb_vm_cref_replace_with_duplicated_cref(), module); return self; } |