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]
This commit is contained in:
Jeremy Evans 2022-08-24 12:32:46 -07:00
parent 07169fd824
commit f5d73da806
Notes: git 2022-11-24 22:26:28 +00:00

11
parse.y
View File

@ -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)) %*/
}