fix: 修复 Function call/apply/bind 调用非原生函数问题

This commit is contained in:
爱特每羊队
2026-06-09 19:12:14 +08:00
parent 8250d34745
commit 3987d39db9
5 changed files with 93 additions and 58 deletions
+9 -2
View File
@@ -445,7 +445,9 @@ impl Vm {
})
}
fn call_function_sync(&mut self, callee: JsValue, receiver: JsValue, args: &[JsValue]) -> Result<JsValue, String> {
pub(crate) fn call_function_sync(
&mut self, callee: JsValue, receiver: JsValue, args: &[JsValue],
) -> Result<JsValue, String> {
if !callee.is_object() {
return Err("TypeError: accessor is not callable".into());
}
@@ -861,7 +863,12 @@ impl Vm {
}
let exc = self.exception_value.take().unwrap_or(JsValue::undefined());
let kind_str = self.pending_error_kind.take().unwrap_or("Error");
let msg = format!("uncaught {kind_str}: {exc}");
let exc_text = self.error_text(exc);
let msg = if exc_text.starts_with(kind_str) {
format!("uncaught {exc_text}")
} else {
format!("uncaught {kind_str}: {exc_text}")
};
Err(msg)
}