Fix throw %!e

This commit is contained in:
Andrew Morris
2023-07-06 14:27:01 +10:00
parent 262ac430f4
commit fcc140c46c
3 changed files with 23 additions and 17 deletions

View File

@@ -1,17 +0,0 @@
//! test_output(E: undefined)
// Should be: "Ok"
// FIXME: This is failing because the optimizer learned to move out of the exception variable. This
// is resulting in a void->undefined conversion (I think), which breaks because we rely on
// throw(void) to not actually throw.
export default function () {
let result: string;
try {
} finally {
result = "Ok";
}
return result;
}

View File

@@ -0,0 +1,12 @@
//! test_output("Ok")
export default function () {
let result: string;
try {
} finally {
result = "Ok";
}
return result;
}

View File

@@ -484,6 +484,17 @@ impl StackFrameTrait for BytecodeStackFrame {
Throw => {
return match self.decoder.peek_type() {
BytecodeType::TakeRegister => {
self.decoder.decode_type();
// Avoid the void->undefined conversion here
let error = take(&mut self.registers[self.decoder.decode_register_index().unwrap()]);
match error {
Val::Void => Ok(FrameStepOk::Continue),
_ => Err(error),
}
}
BytecodeType::Register => {
self.decoder.decode_type();