Fix try: Add set_last_error() to prepare_error_handler() for IR eval (#13838)

# Description

Fixes a bug with `set_last_error()` introduced by @IanManske not being
called during the jump to an error handler in IR eval. Without this,
`$env.LAST_EXIT_CODE` wasn't getting set in the `catch` block for an
external.

# Tests + Formatting

Added a `tests/eval` test to cover this in both IR and non-IR eval
This commit is contained in:
Devyn Cairns
2024-09-13 00:07:22 -07:00
committed by GitHub
parent 5101b5e306
commit a59477205d
2 changed files with 10 additions and 0 deletions

View File

@ -246,6 +246,8 @@ fn prepare_error_handler(
) {
if let Some(reg_id) = error_handler.error_register {
if let Some(error) = error {
// Stack state has to be updated for stuff like LAST_EXIT_CODE
ctx.stack.set_last_error(&error.item);
// Create the error value and put it in the register
ctx.put_reg(
reg_id,