mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Fix throw %!e
This commit is contained in:
@@ -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;
|
||||
}
|
||||
12
inputs/passing/exceptions/finallyWithoutThrow.ts
Normal file
12
inputs/passing/exceptions/finallyWithoutThrow.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
//! test_output("Ok")
|
||||
|
||||
export default function () {
|
||||
let result: string;
|
||||
|
||||
try {
|
||||
} finally {
|
||||
result = "Ok";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user