From c7b9ff04991a4a9dfbc9356e7f92efba93fe9dac Mon Sep 17 00:00:00 2001 From: Leo Date: Wed, 6 Mar 2024 19:28:43 +0700 Subject: [PATCH] fix(boa_engine): fix conversion from undefined to JSON --- core/engine/src/value/conversions/serde_json.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/engine/src/value/conversions/serde_json.rs b/core/engine/src/value/conversions/serde_json.rs index 104d928e7c9..ffee5a55d06 100644 --- a/core/engine/src/value/conversions/serde_json.rs +++ b/core/engine/src/value/conversions/serde_json.rs @@ -115,7 +115,9 @@ impl JsValue { pub fn to_json(&self, context: &mut Context) -> JsResult { match self { Self::Null => Ok(Value::Null), - Self::Undefined => todo!("undefined to JSON"), + Self::Undefined => Err(JsNativeError::typ() + .with_message("cannot convert undefined to JSON") + .into()), &Self::Boolean(b) => Ok(b.into()), Self::String(string) => Ok(string.to_std_string_escaped().into()), &Self::Rational(rat) => Ok(rat.into()),