diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-12-16 01:07:06 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-12-16 02:11:51 +0900 |
commit | 92b10f5be7453aceb5863e46ac775a4ddbf83b97 (patch) | |
tree | e6199a04d020f73ce7410199ef2f3ccf34820b06 /parse.y | |
parent | 1ac0afab4da1986d6eefd421ca3877afd47d2a77 (diff) |
[Bug #20062] Fixed numbered parameter syntax error
At the method definition, the local scope that saves the context of
the numbered parameters needs to be pushed before saving.
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -1104,6 +1104,7 @@ static rb_node_break_t *rb_node_break_new(struct parser_params *p, NODE *nd_stts static rb_node_next_t *rb_node_next_new(struct parser_params *p, NODE *nd_stts, const YYLTYPE *loc); static rb_node_redo_t *rb_node_redo_new(struct parser_params *p, const YYLTYPE *loc); static rb_node_def_temp_t *rb_node_def_temp_new(struct parser_params *p, const YYLTYPE *loc); +static rb_node_def_temp_t *def_head_save(struct parser_params *p, rb_node_def_temp_t *n); #define NEW_BREAK(s,loc) (NODE *)rb_node_break_new(p,s,loc) #define NEW_NEXT(s,loc) (NODE *)rb_node_next_new(p,s,loc) @@ -2694,7 +2695,7 @@ def_name : fname defn_head : k_def def_name { - $$ = $k_def; + $$ = def_head_save(p, $k_def); $$->nd_mid = $def_name; /*%%%*/ $$->nd_def = NEW_DEFN($def_name, 0, &@$); @@ -2712,7 +2713,7 @@ defs_head : k_def singleton dot_or_colon def_name { SET_LEX_STATE(EXPR_ENDFN|EXPR_LABEL); /* force for args */ - $$ = $k_def; + $$ = def_head_save(p, $k_def); $$->nd_mid = $def_name; /*%%%*/ $$->nd_def = NEW_DEFS($singleton, $def_name, 0, &@$); @@ -12260,8 +12261,8 @@ rb_node_def_temp_new(struct parser_params *p, const YYLTYPE *loc) { rb_node_def_temp_t *n = NODE_NEWNODE((enum node_type)NODE_DEF_TEMP, rb_node_def_temp_t, loc); n->save.cur_arg = p->cur_arg; - n->save.numparam_save = numparam_push(p); - n->save.max_numparam = p->max_numparam; + n->save.numparam_save = 0; + n->save.max_numparam = 0; n->save.ctxt = p->ctxt; #ifdef RIPPER n->nd_recv = Qnil; @@ -12275,6 +12276,14 @@ rb_node_def_temp_new(struct parser_params *p, const YYLTYPE *loc) return n; } +static rb_node_def_temp_t * +def_head_save(struct parser_params *p, rb_node_def_temp_t *n) +{ + n->save.numparam_save = numparam_push(p); + n->save.max_numparam = p->max_numparam; + return n; +} + #ifndef RIPPER static enum node_type nodetype(NODE *node) /* for debug */ |