fix: 数组长度定义异常原值抛出并保留错误类型

This commit is contained in:
2026-09-18 02:42:11 +00:00
parent a6411a495d
commit b45f979db7
9 changed files with 144 additions and 33 deletions
+4
View File
@@ -222,6 +222,10 @@ pub struct Vm {
/// String 后,for-of 需要重新抛出原值。放在 VM 顶层字段(不在 InlineSyncState 中)
/// 以便跨内联调用的恢复过程存活。
pub(crate) last_uncaught_value: Option<JsValue>,
/// 数组 length define 强转期用户代码抛出的原始异常:与 `last_uncaught_value`
/// 分离,避免入口误取其它操作忽略调用残留的值。仅 `define_array_length` 写入,
/// 由 Object/Reflect define 入口消费。
pub(crate) pending_length_exception: Option<JsValue>,
pub(crate) pending_exception: Option<JsValue>,
pub(crate) pending_error_kind: Option<&'static str>,
/// 控制流完成(break/continue/return)暂存,finally 执行后由 TRY_FINALLY_END 恢复。
+3
View File
@@ -52,6 +52,9 @@ impl oxide_runtime_api::VmHost for Vm {
fn restore_uncaught_value(&mut self, value: Option<JsValue>) {
self.last_uncaught_value = value;
}
fn take_pending_length_exception(&mut self) -> Option<JsValue> {
self.pending_length_exception.take()
}
fn property_key_si(&mut self, val: JsValue) -> u32 {
// 对象键转换(to_string_full)失败时降级为空键:本 trait 路径供
// Reflect/Object 内置使用,这些内置按规范不传播键转换异常;计算属性