avm2: Implement Error 1112

This commit is contained in:
Lord-McSweeney 2023-10-19 18:32:07 -07:00 committed by Lord-McSweeney
parent 5d2d8e080a
commit b1056311f0
2 changed files with 13 additions and 7 deletions

View File

@ -2,7 +2,7 @@
use crate::avm2::activation::Activation; use crate::avm2::activation::Activation;
use crate::avm2::class::{Allocator, AllocatorFn, Class, ClassHashWrapper}; use crate::avm2::class::{Allocator, AllocatorFn, Class, ClassHashWrapper};
use crate::avm2::error::{make_error_1127, type_error}; use crate::avm2::error::{argument_error, make_error_1127, type_error};
use crate::avm2::function::Executable; use crate::avm2::function::Executable;
use crate::avm2::method::Method; use crate::avm2::method::Method;
use crate::avm2::object::function_object::FunctionObject; use crate::avm2::object::function_object::FunctionObject;
@ -857,11 +857,18 @@ impl<'gc> TObject<'gc> for ClassObject<'gc> {
func.exec(receiver, arguments, activation, self.into()) func.exec(receiver, arguments, activation, self.into())
} else { } else {
arguments if arguments.len() == 1 {
.get(0) arguments[0].coerce_to_type(activation, self.inner_class_definition())
.cloned() } else {
.unwrap_or(Value::Undefined) Err(Error::AvmError(argument_error(
.coerce_to_type(activation, self.inner_class_definition()) activation,
&format!(
"Error #1112: Argument count mismatch on class coercion. Expected 1, got {}.",
arguments.len()
),
1112,
)?))
}
} }
} }

View File

@ -1,2 +1 @@
num_ticks = 1 num_ticks = 1
known_failure = true