/// Resolve function call expression with named arguments
Resolve function call expression with named arguments
Resolve function call expression with named arguments
pub fn named_function_call_expr(
    loc: &pt::Loc,
    ty: &pt::Expression,
    args: &[pt::NamedArgument],
    file_no: usize,
    contract_no: Option<usize>,
    ns: &mut Namespace,
    symtable: &Symtable,
    diagnostics: &mut Vec<Diagnostic>,
) -> Result<Expression, ()> {
    let (ty, call_args, call_args_loc) = collect_call_args(ty, diagnostics)?;
    match ty {
        pt::Expression::MemberAccess(_, member, func) => method_call_named_args(
            loc,
            member,
            func,
            args,
            &call_args,
            call_args_loc,
            file_no,
            contract_no,
            ns,
            symtable,
            diagnostics,
        ),
        pt::Expression::Variable(id) => {
            if let Some(loc) = call_args_loc {
                diagnostics.push(Diagnostic::error(
                    loc,
                    "call arguments not permitted for internal calls".to_string(),
                ));
                return Err(());
            }
            function_call_with_named_args(
                loc,
                &id,
                args,
                file_no,
                available_functions(&id.name, true, file_no, contract_no, ns),
                true,
                contract_no,
                ns,
                symtable,
                diagnostics,
            )
        }
        pt::Expression::ArraySubscript(_, _, _) => {
            diagnostics.push(Diagnostic::error(
                ty.loc(),
                "unexpected array type".to_string(),
            ));
            Err(())
        }
        _ => {
            diagnostics.push(Diagnostic::error(
                ty.loc(),
                "expression not expected here".to_string(),
            ));
            Err(())
        }
    }
}
pub fn named_function_call_expr ( loc : & pt :: Loc , ty : & pt :: Expression , args : & [ pt :: NamedArgument ] , file_no : usize , contract_no : Option < usize > , ns : & mut Namespace , symtable : & Symtable , diagnostics : & mut Vec < Diagnostic > , ) -> Result < Expression , ( ) > { let ( ty , call_args , call_args_loc ) = collect_call_args ( ty , diagnostics ) ? ; match ty { pt :: Expression :: MemberAccess ( _ , member , func ) => method_call_named_args ( loc , member , func , args , & call_args , call_args_loc , file_no , contract_no , ns , symtable , diagnostics , ) , pt :: Expression :: Variable ( id ) => { if let Some ( loc ) = call_args_loc { diagnostics . push ( Diagnostic :: error ( loc , " " . to_string ( ) , ) ) ; return Err ( ( ) ) ; } function_call_with_named_args ( loc , & id , args , file_no , available_functions ( & id . name , true , file_no , contract_no , ns ) , true , contract_no , ns , symtable , diagnostics , ) } pt :: Expression :: ArraySubscript ( _ , _ , _ ) => { diagnostics . push ( Diagnostic :: error ( ty . loc ( ) , " " . to_string ( ) , ) ) ; Err ( ( ) ) } _ => { diagnostics . push ( Diagnostic :: error ( ty . loc ( ) , " " . to_string ( ) , ) ) ; Err ( ( ) ) } } }
Resolve function call expression with named arguments
Resolve function call expression with named arguments
loc
&pt::Loc
ty
&pt::Expression
args
&[pt::NamedArgument]
file_no
usize
contract_no
Option<usize>
ns
&mut Namespace
symtable
&Symtable
diagnostics
&mut Vec<Diagnostic>