summaryrefslogtreecommitdiff
path: root/vm_eval.c
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-06 07:15:18 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-06 07:15:18 +0000
commitd622818377ac5fc255bf9acb7da278b245e76389 (patch)
treee1aabedd0e97ed66468be5f3ca79e3016f144af5 /vm_eval.c
parentc837fe405611cc24faa88f677bd186978fdc97ec (diff)
downloadbundler-d622818377ac5fc255bf9acb7da278b245e76389.tar.gz
* vm_eval.c (eval_string_with_cref): copy cref to limit the scope of
refienements in the eval string. [ruby-core:56329] [Bug #8722] * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/vm_eval.c b/vm_eval.c
index ce61849f2c..4493c1c929 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1186,6 +1186,8 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, volatile V
rb_block_t block, *base_block;
volatile int parse_in_eval;
volatile int mild_compile_error;
+ NODE *orig_cref;
+ VALUE crefval;
if (file == 0) {
file = rb_sourcefilename();
@@ -1243,7 +1245,14 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *cref, volatile V
th->mild_compile_error--;
th->parse_in_eval--;
+ if (!cref && base_block->iseq) {
+ orig_cref = rb_vm_get_cref(base_block->iseq, base_block->ep);
+ cref = NEW_CREF(Qnil);
+ crefval = (VALUE) cref;
+ COPY_CREF(cref, orig_cref);
+ }
vm_set_eval_stack(th, iseqval, cref, base_block);
+ RB_GC_GUARD(crefval);
if (0) { /* for debug */
VALUE disasm = rb_iseq_disasm(iseqval);