diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-12-21 23:03:08 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-12-27 11:05:56 +0900 |
| commit | 7e6355975eff730c1fefc414fbf7c9d0bacbef01 (patch) | |
| tree | 1d98baac2eb0fb2abb0d66e900315c1c23b92dcd | |
| parent | 716102fff38f4067d9b9fcf6bb0ff9e6dbd78105 (diff) | |
| download | mruby-7e6355975eff730c1fefc414fbf7c9d0bacbef01.tar.gz mruby-7e6355975eff730c1fefc414fbf7c9d0bacbef01.zip | |
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.
| -rw-r--r-- | mrbgems/mruby-compiler/core/parse.y | 8 |
1 files 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; |
