diff --git a/core/src/avm2/value.rs b/core/src/avm2/value.rs index d94138611..b3365a4ee 100644 --- a/core/src/avm2/value.rs +++ b/core/src/avm2/value.rs @@ -598,14 +598,18 @@ impl<'gc> Value<'gc> { return Ok(self.coerce_to_number(activation)?.into()); } - if type_name.contains_name(&QName::new(Namespace::public(), "String")) { - return Ok(self.coerce_to_string(activation)?.into()); - } - if type_name.contains_name(&QName::new(Namespace::public(), "Boolean")) { return Ok(self.coerce_to_boolean().into()); } + if matches!(self, Value::Undefined) || matches!(self, Value::Null) { + return Ok(Value::Null); + } + + if type_name.contains_name(&QName::new(Namespace::public(), "String")) { + return Ok(self.coerce_to_string(activation)?.into()); + } + if let Ok(object) = self.coerce_to_object(activation) { let param_type = activation .scope() @@ -623,7 +627,7 @@ impl<'gc> Value<'gc> { } } - //undefined and null, or type is unconstrained + //type is unconstrained Ok(self.clone()) }