Array: Fix Array single-param ctor
The Array constructor with a single param sets the length if the parameter is a number (no coercion is done); otherwise, it is creates an 1-length Array containing the parameter. Previously we coerced the parameter to a float.
This commit is contained in:
parent
9e13058e04
commit
366e8aa926
|
@ -91,7 +91,7 @@ pub fn constructor<'gc>(
|
|||
|
||||
if args.len() == 1 {
|
||||
let arg = args.get(0).unwrap();
|
||||
if let Ok(length) = arg.coerce_to_f64(activation) {
|
||||
if let Value::Number(length) = *arg {
|
||||
if length >= 0.0 {
|
||||
this.set_length(activation.context.gc_context, length as usize);
|
||||
consumed = true;
|
||||
|
@ -124,7 +124,7 @@ pub fn array_function<'gc>(
|
|||
|
||||
if args.len() == 1 {
|
||||
let arg = args.get(0).unwrap();
|
||||
if let Ok(length) = arg.coerce_to_f64(activation) {
|
||||
if let Value::Number(length) = *arg {
|
||||
if length >= 0.0 {
|
||||
array_obj.set_length(activation.context.gc_context, length as usize);
|
||||
consumed = true;
|
||||
|
|
Loading…
Reference in New Issue