Skip to content

Commit

Permalink
fix(boa_engine): fix conversion from undefined to JSON
Browse files Browse the repository at this point in the history
  • Loading branch information
ryutamago committed Mar 6, 2024
1 parent 41b24d5 commit 78c8540
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions boa_engine/src/value/conversions/serde_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,12 @@ impl JsValue {
/// #
/// # assert_eq!(json, back_to_json);
/// ```
///
/// # Panics
///
/// Panics if the `JsValue` is `Undefined`.
pub fn to_json(&self, context: &mut Context<'_>) -> JsResult<Value> {
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()),
Expand Down

0 comments on commit 78c8540

Please sign in to comment.