avm2: `undefined` is normalized to `null` for string and object coercions
This commit is contained in:
parent
4122c1b96e
commit
abc9d0800a
|
@ -598,14 +598,18 @@ impl<'gc> Value<'gc> {
|
||||||
return Ok(self.coerce_to_number(activation)?.into());
|
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")) {
|
if type_name.contains_name(&QName::new(Namespace::public(), "Boolean")) {
|
||||||
return Ok(self.coerce_to_boolean().into());
|
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) {
|
if let Ok(object) = self.coerce_to_object(activation) {
|
||||||
let param_type = activation
|
let param_type = activation
|
||||||
.scope()
|
.scope()
|
||||||
|
@ -623,7 +627,7 @@ impl<'gc> Value<'gc> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//undefined and null, or type is unconstrained
|
//type is unconstrained
|
||||||
Ok(self.clone())
|
Ok(self.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue