engine: ToPropertyKey via ToPrimitive, Symbol keys/description, catchable conversion errors

This commit is contained in:
爱特每羊队
2026-08-12 09:59:56 +08:00
parent 18eb6ef8ab
commit c4fda0f883
16 changed files with 265 additions and 86 deletions
+10 -1
View File
@@ -190,7 +190,16 @@ pub fn date_constructor<H: VmHost>(vm: &mut H, args: &[u8]) -> NativeResult {
let obj = unsafe { &*val.as_js_object_ptr() };
get_timestamp(obj)
} else {
f64::NAN
match oxide_runtime_api::to_number_full(val, vm) {
Ok(n) => n,
Err(_) => {
// ToNumber on an object may throw via toString/valueOf; propagate the original exception.
if let Some(exc) = vm.take_uncaught_value() {
return NativeResult::Err(exc);
}
return NativeResult::Err(crate::error::create_type_error(vm, "Cannot convert value to a number"));
}
}
}
};