Skip to content

Commit

Permalink
parse.y: numbered parameters should not appear on toplevel.
Browse files Browse the repository at this point in the history
Toplevel includes the top of the method/class/module definitions.
  • Loading branch information
matz committed Jan 11, 2022
1 parent 3a30cc2 commit 7e7f1b2
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions mrbgems/mruby-compiler/core/parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -6422,15 +6422,17 @@ parser_yylex(parser_state *p)
nvars = nvars->cdr;
}
nvar = intn(p->nvars->car);
if (nvar == -1) {
yywarning(p, "numbered parameter used in inner block");
}
else {
p->nvars->car = nint(nvar > n ? nvar : n);
if (nvar != -2) { /* numbered parameters never appear on toplevel */
if (nvar == -1) {
yywarning(p, "numbered parameter used in inner block");
}
else {
p->nvars->car = nint(nvar > n ? nvar : n);
}
pylval.num = n;
p->lstate = EXPR_END;
return tNUMPARAM;
}
pylval.num = n;
p->lstate = EXPR_END;
return tNUMPARAM;
}
}
/* fall through */
Expand Down

0 comments on commit 7e7f1b2

Please sign in to comment.