@@ -909,34 +909,27 @@ impl<'gc> Value<'gc> {
909
909
name : Option < & Multiname < ' gc > > ,
910
910
receiver : Option < Object < ' gc > > ,
911
911
) -> Result < Object < ' gc > , Error < ' gc > > {
912
- self . as_object ( )
913
- . filter ( |o| o. as_class_object ( ) . is_some ( ) || o. as_executable ( ) . is_some ( ) )
914
- . ok_or_else ( || {
915
- if let Some ( receiver) = receiver {
916
- if let Some ( name) = name {
917
- format ! (
918
- "Cannot call null or undefined method {} of class {}" ,
919
- name. to_qualified_name( activation. context. gc_context) ,
920
- receiver. instance_of_class_name( activation. context. gc_context)
921
- )
922
- . into ( )
923
- } else {
924
- format ! (
925
- "Cannot call null or undefined method of class {}" ,
926
- receiver. instance_of_class_name( activation. context. gc_context)
927
- )
928
- . into ( )
929
- }
930
- } else if let Some ( name) = name {
912
+ match self . as_object ( ) {
913
+ Some ( o) if o. as_class_object ( ) . is_some ( ) || o. as_executable ( ) . is_some ( ) => Ok ( o) ,
914
+ _ => {
915
+ // Undefined function
916
+ let name = if let Some ( name) = name {
917
+ name. to_qualified_name ( activation. context . gc_context )
918
+ } else {
919
+ "value" . into ( )
920
+ } ;
921
+ let msg = if let Some ( receiver) = receiver {
931
922
format ! (
932
- "Cannot call null or undefined function {}" ,
933
- name. to_qualified_name( activation. context. gc_context)
923
+ "Error #1006: {} is not a function of class {}." ,
924
+ name,
925
+ receiver. instance_of_class_name( activation. context. gc_context)
934
926
)
935
- . into ( )
936
927
} else {
937
- "Cannot call null or undefined function" . into ( )
938
- }
939
- } )
928
+ format ! ( "Error #1006: {} is not a function." , name)
929
+ } ;
930
+ Err ( Error :: AvmError ( type_error ( activation, & msg, 1006 ) ?) )
931
+ }
932
+ }
940
933
}
941
934
942
935
/// Like `coerce_to_type`, but also performs resolution of the type name.
0 commit comments