diff options
author | Shugo Maeda <shugo@ruby-lang.org> | 2022-11-28 10:40:08 +0900 |
---|---|---|
committer | Shugo Maeda <shugo.maeda@gmail.com> | 2022-11-29 11:22:09 +0900 |
commit | 4fc668a4f3b9b67cc7566096ab55cab34c67c158 (patch) | |
tree | b4fc3295087b50c46345f6c5ca3d754b2c4d3fe8 /parse.y | |
parent | ee49fe5d34c1498a532bbaeaf4c12b162d0df78f (diff) | |
download | ruby-4fc668a4f3b9b67cc7566096ab55cab34c67c158.tar.gz |
Allow ** in def foo(...)
[Feature #19134]
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 20 |
1 files changed, 4 insertions, 16 deletions
@@ -944,11 +944,7 @@ static void numparam_pop(struct parser_params *p, NODE *prev_inner); #endif #define idFWD_REST '*' -#ifdef RUBY3_KEYWORDS #define idFWD_KWREST idPow /* Use simple "**", as tDSTAR is "**arg" */ -#else -#define idFWD_KWREST 0 -#endif #define idFWD_BLOCK '&' #define RE_OPTION_ONCE (1<<16) @@ -12581,7 +12577,7 @@ new_args(struct parser_params *p, NODE *pre_args, NODE *opt_args, ID rest_arg, N args->opt_args = opt_args; - args->ruby2_keywords = args->forwarding; + args->ruby2_keywords = 0; p->ruby_sourceline = saved_line; nd_set_loc(tail, loc); @@ -13266,9 +13262,7 @@ static int check_forwarding_args(struct parser_params *p) { if (local_id(p, idFWD_REST) && -#if idFWD_KWREST local_id(p, idFWD_KWREST) && -#endif local_id(p, idFWD_BLOCK)) return TRUE; compile_error(p, "unexpected ..."); return FALSE; @@ -13278,9 +13272,7 @@ static void add_forwarding_args(struct parser_params *p) { arg_var(p, idFWD_REST); -#if idFWD_KWREST arg_var(p, idFWD_KWREST); -#endif arg_var(p, idFWD_BLOCK); } @@ -13288,15 +13280,11 @@ add_forwarding_args(struct parser_params *p) static NODE * new_args_forward_call(struct parser_params *p, NODE *leading, const YYLTYPE *loc, const YYLTYPE *argsloc) { - NODE *splat = NEW_SPLAT(NEW_LVAR(idFWD_REST, loc), loc); -#if idFWD_KWREST + NODE *rest = NEW_LVAR(idFWD_REST, loc); NODE *kwrest = list_append(p, NEW_LIST(0, loc), NEW_LVAR(idFWD_KWREST, loc)); -#endif NODE *block = NEW_BLOCK_PASS(NEW_LVAR(idFWD_BLOCK, loc), loc); - NODE *args = leading ? rest_arg_append(p, leading, splat, argsloc) : splat; -#if idFWD_KWREST - args = arg_append(p, splat, new_hash(p, kwrest, loc), loc); -#endif + NODE *args = leading ? rest_arg_append(p, leading, rest, loc) : NEW_SPLAT(rest, loc); + args = arg_append(p, args, new_hash(p, kwrest, loc), loc); return arg_blk_pass(args, block); } #endif |