avm2: `undefined` is normalized to `null` for string and object coercions

This commit is contained in:
David Wendt 2021-06-10 22:57:09 -04:00
parent 4122c1b96e
commit abc9d0800a
1 changed files with 9 additions and 5 deletions

View File

@ -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())
}