Skip to content

Commit

Permalink
Fix the position of rescue clause without exc_list
Browse files Browse the repository at this point in the history
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
688169f when "opt_list" was split
into "exc_list exc_var".

Fixes [Bug #18974]
  • Loading branch information
jeremyevans committed Nov 24, 2022
1 parent 07169fd commit f5d73da
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion parse.y
Expand Up @@ -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)) %*/
}
Expand Down

0 comments on commit f5d73da

Please sign in to comment.