diff options
| author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-25 19:52:47 +0900 |
|---|---|---|
| committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2023-09-25 23:04:09 +0900 |
| commit | 56604c7a3bb5ee8485baf84c100d5662a2666176 (patch) | |
| tree | 3c1fc7aa52ccd8876c118832941feb7e3f14e22d | |
| parent | 4449dcac15c64d93462babaacb6fd8bf4c5d3c6b (diff) | |
Split the build of `RESBODY` nodes
| -rw-r--r-- | parse.y | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -1976,7 +1976,10 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ YYLTYPE loc = code_loc_gen(&@5, &@6); - $$ = node_assign(p, $1, NEW_RESCUE($4, NEW_RESBODY(0, remove_begin($6), 0, &loc), 0, &@$), $3, &@$); + NODE *resbody = NEW_RESBODY(0, remove_begin($6), 0, &loc); + loc.beg_pos = @4.beg_pos; + NODE *rhs = NEW_RESCUE($4, resbody, 0, &loc); + $$ = node_assign(p, $1, rhs, $3, &@$); /*% %*/ /*% ripper: massign!($1, rescue_mod!($4, $6)) %*/ } @@ -5061,10 +5064,13 @@ opt_rescue : k_rescue exc_list exc_var then opt_rescue { /*%%%*/ - $$ = NEW_RESBODY($2, - $3 ? block_append(p, node_assign(p, $3, NEW_ERRINFO(&@3), NO_LEX_CTXT, &@3), $5) : $5, - $6, &@$); - + NODE *body = $5; + if ($3) { + NODE *err = NEW_ERRINFO(&@3); + err = node_assign(p, $3, err, NO_LEX_CTXT, &@3); + body = block_append(p, err, body); + } + $$ = NEW_RESBODY($2, body, $6, &@$); if ($2) { fixpos($$, $2); } |
