fn check_assignment_compatibility<T>(
    loc: &pt::Loc,
    lhs: &[T],
    rhs: &YulExpression,
    context: &ExprContext,
    function_table: &FunctionsTable,
    symtable: &mut Symtable,
    ns: &mut Namespace,
) {
    match rhs {
        YulExpression::FunctionCall(_, function_no, ..) => {
            let func = function_table.get(*function_no).unwrap();
            if func.returns.len() != lhs.len() {
                ns.diagnostics.push(Diagnostic::error(
                    *loc,
                    format!(
                        "{} variables on the left hand side, but the function returns {} values",
                        lhs.len(),
                        func.returns.len()
                    ),
                ));
            }
        }

        YulExpression::BuiltInCall(_, ty, _) => {
            let prototype = ty.get_prototype_info();
            if prototype.no_returns as usize != lhs.len() {
                ns.diagnostics.push(Diagnostic::error(
                    *loc,
                    format!(
                        "{} variables on the left hand side, but the function returns {} values",
                        lhs.len(),
                        prototype.no_returns
                    ),
                ));
            }
        }

        _ => {
            if lhs.len() != 1 {
                ns.diagnostics.push(Diagnostic::error(
                    *loc,
                    "a single value cannot be assigned to multiple variables".to_string(),
                ));
            } else if let Some(diagnostic) = check_type(rhs, context, ns, symtable) {
                ns.diagnostics.push(diagnostic);
            }
        }
    }
}
/// Checks the the left hand side of an assignment is compatible with it right hand side
Checks the the left hand side of an assignment is compatible with it right hand side
Checks the the left hand side of an assignment is compatible with it right hand side
fn check_assignment_compatibility<T>(
    loc: &pt::Loc,
    lhs: &[T],
    rhs: &YulExpression,
    context: &ExprContext,
    function_table: &FunctionsTable,
    symtable: &mut Symtable,
    ns: &mut Namespace,
) {
    match rhs {
        YulExpression::FunctionCall(_, function_no, ..) => {
            let func = function_table.get(*function_no).unwrap();
            if func.returns.len() != lhs.len() {
                ns.diagnostics.push(Diagnostic::error(
                    *loc,
                    format!(
                        "{} variables on the left hand side, but the function returns {} values",
                        lhs.len(),
                        func.returns.len()
                    ),
                ));
            }
        }
        YulExpression::BuiltInCall(_, ty, _) => {
            let prototype = ty.get_prototype_info();
            if prototype.no_returns as usize != lhs.len() {
                ns.diagnostics.push(Diagnostic::error(
                    *loc,
                    format!(
                        "{} variables on the left hand side, but the function returns {} values",
                        lhs.len(),
                        prototype.no_returns
                    ),
                ));
            }
        }
        _ => {
            if lhs.len() != 1 {
                ns.diagnostics.push(Diagnostic::error(
                    *loc,
                    "a single value cannot be assigned to multiple variables".to_string(),
                ));
            } else if let Some(diagnostic) = check_type(rhs, context, ns, symtable) {
                ns.diagnostics.push(diagnostic);
            }
        }
    }
}
fn check_assignment_compatibility < T > ( loc : & pt :: Loc , lhs : & [ T ] , rhs : & YulExpression , context : & ExprContext , function_table : & FunctionsTable , symtable : & mut Symtable , ns : & mut Namespace , ) { match rhs { YulExpression :: FunctionCall ( _ , function_no , .. ) => { let func = function_table . get ( * function_no ) . unwrap ( ) ; if func . returns . len ( ) != lhs . len ( ) { ns . diagnostics . push ( Diagnostic :: error ( * loc , format ! ( " " lhs len ( ) func returns len ( ) ) , ) ) ; } } YulExpression :: BuiltInCall ( _ , ty , _ ) => { let prototype = ty . get_prototype_info ( ) ; if prototype . no_returns as usize != lhs . len ( ) { ns . diagnostics . push ( Diagnostic :: error ( * loc , format ! ( " " lhs len ( ) prototype no_returns ) , ) ) ; } } _ => { if lhs . len ( ) != 1 { ns . diagnostics . push ( Diagnostic :: error ( * loc , " " . to_string ( ) , ) ) ; } else if let Some ( diagnostic ) = check_type ( rhs , context , ns , symtable ) { ns . diagnostics . push ( diagnostic ) ; } } } }
Checks the the left hand side of an assignment is compatible with it right hand side
Checks the the left hand side of an assignment is compatible with it right hand side
loc
&pt::Loc
lhs
&[T]
rhs
&YulExpression
context
&ExprContext
function_table
&FunctionsTable
symtable
&mut Symtable
ns
&mut Namespace
loc
&pt::Loc
lhs
&[T]
rhs
&YulExpression
context
&ExprContext
function_table
&FunctionsTable
symtable
&mut Symtable
ns
&mut Namespace