fixed. closures scope in eval(string)

This commit is contained in:
Satoshi Odawara
2014-09-29 16:41:51 +09:00
parent b090f43251
commit 2551d14ff1
2 changed files with 18 additions and 4 deletions
+13 -4
View File
@@ -53,13 +53,22 @@ patch_irep(mrb_state *mrb, mrb_irep *irep, int bnest)
size_t i;
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++) {
c = irep->iseq[i];
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:
if (GETARG_C(c) != 0) {
break;
+5
View File
@@ -32,6 +32,11 @@ assert('Kernel.eval', '15.3.1.2.3') do
}.call
c
}
assert_equal(2) {
a = 10
Kernel.eval 'def f(a); b=a.send(:+, 1); end'
f(1)
}
end
assert('Kernel#eval', '15.3.1.3.12') do