Commit d85cce95 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2598 from SatoshiOdawara/fix_lv_scope_eval

fixed. closures scope in eval(string)
parents b090f432 2551d14f
...@@ -53,13 +53,22 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest) ...@@ -53,13 +53,22 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest)
size_t i; size_t i;
mrb_code c; mrb_code c;
for (i = 0; i < irep->rlen; i++) {
patch_irep(mrb, irep->reps[i], bnest + 1);
}
for (i = 0; i < irep->ilen; i++) { for (i = 0; i < irep->ilen; i++) {
c = irep->iseq[i]; c = irep->iseq[i];
switch(GET_OPCODE(c)){ switch(GET_OPCODE(c)){
case OP_EPUSH:
patch_irep(mrb, irep->reps[GETARG_Bx(c)], bnest + 1);
break;
case OP_LAMBDA:
{
int arg_c = GETARG_c(c);
if (arg_c & OP_L_CAPTURE) {
patch_irep(mrb, irep->reps[GETARG_b(c)], bnest + 1);
}
}
break;
case OP_SEND: case OP_SEND:
if (GETARG_C(c) != 0) { if (GETARG_C(c) != 0) {
break; break;
......
...@@ -32,6 +32,11 @@ assert('Kernel.eval', '15.3.1.2.3') do ...@@ -32,6 +32,11 @@ assert('Kernel.eval', '15.3.1.2.3') do
}.call }.call
c c
} }
assert_equal(2) {
a = 10
Kernel.eval 'def f(a); b=a.send(:+, 1); end'
f(1)
}
end end
assert('Kernel#eval', '15.3.1.3.12') do assert('Kernel#eval', '15.3.1.3.12') do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment