@@ -96,6 +96,7 @@ pub mod try_which;
9696pub enum FunctionArgKind {
9797 Array ,
9898 Boolean ,
99+ Lambda ,
99100 Null ,
100101 Number ,
101102 Object ,
@@ -107,6 +108,7 @@ impl Display for FunctionArgKind {
107108 match self {
108109 FunctionArgKind :: Array => write ! ( f, "Array" ) ,
109110 FunctionArgKind :: Boolean => write ! ( f, "Boolean" ) ,
111+ FunctionArgKind :: Lambda => write ! ( f, "Lambda" ) ,
110112 FunctionArgKind :: Null => write ! ( f, "Null" ) ,
111113 FunctionArgKind :: Number => write ! ( f, "Number" ) ,
112114 FunctionArgKind :: Object => write ! ( f, "Object" ) ,
@@ -353,17 +355,21 @@ impl FunctionDispatcher {
353355 }
354356
355357 fn check_arg_against_expected_types ( name : & str , arg : & Value , expected_types : & [ FunctionArgKind ] ) -> Result < ( ) , DscError > {
358+ let is_lambda = arg. as_str ( ) . is_some_and ( |s| s. starts_with ( "__lambda_" ) ) ;
359+
356360 if arg. is_array ( ) && !expected_types. contains ( & FunctionArgKind :: Array ) {
357361 return Err ( DscError :: Parser ( t ! ( "functions.noArrayArgs" , name = name, accepted_args_string = expected_types. iter( ) . map( std:: string:: ToString :: to_string) . collect:: <Vec <_>>( ) . join( ", " ) ) . to_string ( ) ) ) ;
358362 } else if arg. is_boolean ( ) && !expected_types. contains ( & FunctionArgKind :: Boolean ) {
359363 return Err ( DscError :: Parser ( t ! ( "functions.noBooleanArgs" , name = name, accepted_args_string = expected_types. iter( ) . map( std:: string:: ToString :: to_string) . collect:: <Vec <_>>( ) . join( ", " ) ) . to_string ( ) ) ) ;
364+ } else if is_lambda && !expected_types. contains ( & FunctionArgKind :: Lambda ) {
365+ return Err ( DscError :: Parser ( t ! ( "functions.noLambdaArgs" , name = name, accepted_args_string = expected_types. iter( ) . map( std:: string:: ToString :: to_string) . collect:: <Vec <_>>( ) . join( ", " ) ) . to_string ( ) ) ) ;
360366 } else if arg. is_null ( ) && !expected_types. contains ( & FunctionArgKind :: Null ) {
361367 return Err ( DscError :: Parser ( t ! ( "functions.noNullArgs" , name = name, accepted_args_string = expected_types. iter( ) . map( std:: string:: ToString :: to_string) . collect:: <Vec <_>>( ) . join( ", " ) ) . to_string ( ) ) ) ;
362368 } else if arg. is_number ( ) && !expected_types. contains ( & FunctionArgKind :: Number ) {
363369 return Err ( DscError :: Parser ( t ! ( "functions.noNumberArgs" , name = name, accepted_args_string = expected_types. iter( ) . map( std:: string:: ToString :: to_string) . collect:: <Vec <_>>( ) . join( ", " ) ) . to_string ( ) ) ) ;
364370 } else if arg. is_object ( ) && !expected_types. contains ( & FunctionArgKind :: Object ) {
365371 return Err ( DscError :: Parser ( t ! ( "functions.noObjectArgs" , name = name, accepted_args_string = expected_types. iter( ) . map( std:: string:: ToString :: to_string) . collect:: <Vec <_>>( ) . join( ", " ) ) . to_string ( ) ) ) ;
366- } else if arg. is_string ( ) && !expected_types. contains ( & FunctionArgKind :: String ) {
372+ } else if arg. is_string ( ) && !is_lambda && ! expected_types. contains ( & FunctionArgKind :: String ) {
367373 return Err ( DscError :: Parser ( t ! ( "functions.noStringArgs" , name = name, accepted_args_string = expected_types. iter( ) . map( std:: string:: ToString :: to_string) . collect:: <Vec <_>>( ) . join( ", " ) ) . to_string ( ) ) ) ;
368374 }
369375 Ok ( ( ) )
0 commit comments