From f5d73da8062377e5b93100c6ea109a37bd04b4c1 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Wed, 24 Aug 2022 12:32:46 -0700 Subject: Fix the position of rescue clause without exc_list If the rescue clause has only exc_var and not exc_list, use the exc_var position instead of the rescue body position. This issue appears to have been introduced in 688169fd83b24564b653c03977c168cea50ccd35 when "opt_list" was split into "exc_list exc_var". Fixes [Bug #18974] --- parse.y | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index c93b8eda59..0a2aa6f1bc 100644 --- a/parse.y +++ b/parse.y @@ -4948,7 +4948,16 @@ opt_rescue : k_rescue exc_list exc_var then $$ = NEW_RESBODY($2, $3 ? block_append(p, node_assign(p, $3, NEW_ERRINFO(&@3), NO_LEX_CTXT, &@3), $5) : $5, $6, &@$); - fixpos($$, $2?$2:$5); + + if ($2) { + fixpos($$, $2); + } + else if ($3) { + fixpos($$, $3); + } + else { + fixpos($$, $5); + } /*% %*/ /*% ripper: rescue!(escape_Qundef($2), escape_Qundef($3), escape_Qundef($5), escape_Qundef($6)) %*/ } -- cgit v1.2.3