parse.y: allow inner anonymous block argument.
MODIFY
mrbgems/mruby-compiler/core/codegen.c
mrbgems/mruby-compiler/core/codegen.c
@@ -1282,7 +1282,12 @@ search_upvar(codegen_scope *s, mrb_sym id, int *idx)
lv ++;
}
+ if (id == MRB_OPSYM_2(s->mrb, and)) {
+ codegen_error(s, "no anonymous block argument");
+ }
+ else {
codegen_error(s, "Can't found local variables");
+ }
return -1; /* not reached */
}
@@ -3261,9 +3266,11 @@ codegen(codegen_scope *s, node *tree, int val)
int idx = lv_idx(s, MRB_OPSYM_2(s->mrb, and));
if (idx == 0) {
- codegen_error(s, "no anonymous block argument");
+ gen_getupvar(s, cursp(), MRB_OPSYM_2(s->mrb, and));
}
+ else {
gen_move(s, cursp(), idx, val);
+ }
if (val) push();
}
else {

MODIFY
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
@@ -328,7 +328,7 @@ static void
local_add_blk(parser_state *p, mrb_sym blk)
{
/* allocate register for block */
- local_add_f(p, blk ? blk : intern_op(and));
+ local_add_f(p, blk ? blk : 0);
}
static void
@@ -3816,7 +3816,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_args_tail
}
| /* none */
{
- local_add_f(p, intern_op(and));
+ local_add_f(p, 0);
$$ = new_args(p, 0, 0, 0, 0, 0);
}
;

MODIFY
mrbgems/mruby-compiler/core/y.tab.c
mrbgems/mruby-compiler/core/y.tab.c
@@ -391,7 +391,7 @@ static void
local_add_blk(parser_state *p, mrb_sym blk)
{
/* allocate register for block */
- local_add_f(p, blk ? blk : intern_op(and));
+ local_add_f(p, blk ? blk : 0);
}
static void
@@ -9734,7 +9734,7 @@ yyreduce:
case 541:
#line 3818 "mrbgems/mruby-compiler/core/parse.y"
{
- local_add_f(p, intern_op(and));
+ local_add_f(p, 0);
(yyval.nd) = new_args(p, 0, 0, 0, 0, 0);
}
#line 9741 "mrbgems/mruby-compiler/core/y.tab.c"

parse.y: allow inner anonymous block argument.