Numbered parameters should not be available in the lambda bodies.
`mruby` does not warn like `CRuby` for cases like
Fix fix fix
MODIFY
mrbgems/mruby-compiler/core/parse.y
mrbgems/mruby-compiler/core/parse.y
@@ -838,7 +838,7 @@ new_block_arg(parser_state *p, node *a)
}
static node*
-setup_args(parser_state *p, node *a)
+setup_numparams(parser_state *p, node *a)
{
int nvars = intn(p->nvars->cdr);
if (nvars > 0) {
@@ -847,7 +847,8 @@ setup_args(parser_state *p, node *a)
// m || opt || rest || tail
if (a && (a->car || (a->cdr && a->cdr->car) || (a->cdr->cdr && a->cdr->cdr->car) || (a->cdr->cdr->cdr->cdr && a->cdr->cdr->cdr->cdr->car))) {
yyerror(p, "ordinary parameter is defined");
- } else {
+ }
+ else {
node* args = 0;
for (i = nvars; i > 0; i--) {
char buf[3];
@@ -869,7 +870,7 @@ setup_args(parser_state *p, node *a)
static node*
new_block(parser_state *p, node *a, node *b)
{
- a = setup_args(p, a);
+ a = setup_numparams(p, a);
return list4((node*)NODE_BLOCK, locals_node(p), a, b);
}
@@ -877,7 +878,6 @@ new_block(parser_state *p, node *a, node *b)
static node*
new_lambda(parser_state *p, node *a, node *b)
{
- a = setup_args(p, a);
return list4((node*)NODE_LAMBDA, locals_node(p), a, b);
}
@@ -2480,7 +2480,6 @@ primary : literal
| tLAMBDA
{
local_nest(p);
- nvars_nest(p);
$<num>$ = p->lpar_beg;
p->lpar_beg = ++p->paren_nest;
}
@@ -2494,7 +2493,6 @@ primary : literal
p->lpar_beg = $<num>2;
$$ = new_lambda(p, $3, $5);
local_unnest(p);
- nvars_unnest(p);
p->cmdarg_stack = $<stack>4;
CMDARG_LEXPOP();
}

MODIFY
test/t/syntax.rb
test/t/syntax.rb
@@ -674,9 +674,6 @@ end
assert('numbered parameters') do
assert_equal(15, [1,2,3,4,5].reduce {_1+_2})
- assert_equal(3, ->{_1+_2}.call(1,2))
- assert_equal(4, ->(a=->{_1}){a}.call.call(4))
- assert_equal(5, -> a: ->{_1} {a}.call.call(5))
assert_equal(45, Proc.new do _1 + _2 + _3 + _4 + _5 + _6 + _7 + _8 + _9 end.call(*[1, 2, 3, 4, 5, 6, 7, 8, 9]))
end

Numbered parameters should not be available in the lambda bodies.

`mruby` does not warn like `CRuby` for cases like #4893.
Fix #4890, fix #4891, fix #4893.