mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
fix: 修复 NEW_EXPRESSION 异常未进入 unwind
This commit is contained in:
@@ -964,14 +964,25 @@ impl Vm {
|
||||
}
|
||||
}
|
||||
Err(err_val) => {
|
||||
return Err(format!("Native constructor error: {:?}", err_val));
|
||||
self.exception_value = Some(err_val);
|
||||
self.pending_error_kind = Some("Error");
|
||||
match self.unwind() {
|
||||
Ok(()) => continue,
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Bytecode constructor - wired in plan 12.1-03
|
||||
return Err(
|
||||
"NEW_EXPRESSION: bytecode constructors not yet supported".into()
|
||||
let error = crate::builtins::error::create_error(
|
||||
self,
|
||||
"NEW_EXPRESSION: bytecode constructors not yet supported",
|
||||
);
|
||||
self.exception_value = Some(error);
|
||||
self.pending_error_kind = Some("Error");
|
||||
match self.unwind() {
|
||||
Ok(()) => continue,
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,3 +106,21 @@ fn regression_vm_step_limit_is_configurable() {
|
||||
"expected configurable step limit error, got: {result}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_new_expression_native_constructor_error_is_catchable() {
|
||||
assert_eq!(
|
||||
eval("try { new RegExp('['); 0 } catch (e) { 1 }"),
|
||||
"1",
|
||||
"expected native constructor error to enter catch"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regression_new_expression_bytecode_constructor_error_is_catchable() {
|
||||
assert_eq!(
|
||||
eval("try { function C() {} new C(); 0 } catch (e) { 1 }"),
|
||||
"1",
|
||||
"expected bytecode constructor capability error to enter catch"
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user