From 7e6355975eff730c1fefc414fbf7c9d0bacbef01 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 21 Dec 2019 23:03:08 +0900 Subject: Prohibit numbered parameters as method arguments; fix #4892 As of CRuby2.7 it is only warned. `mruby` prohibits explicitly to implement the future Ruby3 behavior. --- mrbgems/mruby-compiler/core/parse.y | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mrbgems/mruby-compiler/core/parse.y b/mrbgems/mruby-compiler/core/parse.y index de875a1ae..ddf420d17 100644 --- a/mrbgems/mruby-compiler/core/parse.y +++ b/mrbgems/mruby-compiler/core/parse.y @@ -3538,6 +3538,11 @@ f_bad_arg : tCONSTANT yyerror(p, "formal argument cannot be a class variable"); $$ = 0; } + | tNUMPARAM + { + yyerror(p, "formal argument cannot be a numbered parameter"); + $$ = 0; + } ; f_norm_arg : f_bad_arg @@ -5969,9 +5974,6 @@ parser_yylex(parser_state *p) nvars->cdr = nint(-1); nvars = nvars->car; } - if (intn(p->nvars->cdr) < 0) { - yywarning(p, "numbered parameter in nested block"); - } pylval.num = n; p->lstate = EXPR_END; return tNUMPARAM; -- cgit v1.2.3