From 3675da72daaa69f9ebc2deae0d67549a5c8eba58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=88=B1=E7=89=B9=E6=AF=8F=E7=BE=8A=E9=98=9F?= Date: Sat, 6 Jun 2026 21:55:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20object=20=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E8=BD=AC=E6=8D=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_vm/src/coercion.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/crates/oxide_vm/src/coercion.rs b/crates/oxide_vm/src/coercion.rs index f01d083..10c7a2c 100644 --- a/crates/oxide_vm/src/coercion.rs +++ b/crates/oxide_vm/src/coercion.rs @@ -5,9 +5,6 @@ use oxide_types::shape::EMPTY_SHAPE_ID; use oxide_types::value::JsValue; pub fn to_primitive(val: JsValue) -> JsValue { - if val.is_object() { - panic_to_object(); - } val } @@ -34,7 +31,7 @@ pub fn to_number(val: JsValue, string_forge: &StringForge) -> f64 { return s.parse::().unwrap_or(f64::NAN); } if val.is_object() { - panic_to_object(); + return f64::NAN; } f64::NAN } @@ -76,7 +73,7 @@ pub fn to_string(string_forge: &StringForge, val: JsValue) -> String { .unwrap_or_default(); } if val.is_object() { - panic_to_object(); + return "[object]".to_string(); } String::new() } @@ -148,7 +145,7 @@ pub fn abstract_eq(lhs: JsValue, rhs: JsValue, string_forge: &StringForge) -> bo return false; } if lhs.is_object() || rhs.is_object() { - panic_to_object(); + return lhs.is_object() && rhs.is_object() && lhs.as_ptr() == rhs.as_ptr(); } false } @@ -210,10 +207,6 @@ pub fn string_concat(lhs: &str, rhs: &str) -> String { s } -fn panic_to_object() -> ! { - panic!("ToObject failed: null or undefined cannot be converted to object") -} - pub fn same_value(lhs: JsValue, rhs: JsValue) -> bool { if lhs.is_double() && rhs.is_double() { let a = lhs.as_double();