Code review comment: IIMO, giving an error for the first scenario is a bug because it can be invoked using position arguments. Therefore, if we try to invoke it with named arguments,error should be raised in that instance. ```ballerina type Foo record {|     int r; |};   function fn(int r, *Foo x) {  } public function main() {     Foo f = {r: 1};     fn(1, f); } ```

Code under review:
private BType checkInvocationParam(BLangInvocation iExpr, AnalyzerData data) {
        if (Symbols.isFlagOn(iExpr.symbol.type.flags, Flags.ANY_FUNCTION)) {
            dlog.error(iExpr.pos, DiagnosticErrorCode.INVALID_FUNCTION_POINTER_INVOCATION_WITH_TYPE);
            return symTable.semanticError;
        }
        BType invocableType = Types.getReferredType(iExpr.symbol.type);
        if (invocableType.tag != TypeTags.INVOKABLE) {
            dlog.error(iExpr.pos, DiagnosticErrorCode.INVALID_FUNCTION_INVOCATION, iExpr.symbol.type);
            return symTable.noType;
        }

        BInvokableSymbol invokableSymbol = ((BInvokableSymbol) iExpr.symbol);
        List<BType> paramTypes = ((BInvokableType) invocableType).getParameterTypes();
        List<BVarSymbol> incRecordParams = new ArrayList<>();
        BVarSymbol incRecordParamAllowAdditionalFields = checkForIncRecordParamAllowAdditionalFields(invokableSymbol,
                                                                                                     incRecordParams);
        int parameterCountForPositionalArgs = paramTypes.size();
        int parameterCountForNamedArgs = parameterCountForPositionalArgs + incRecordParams.size();
        iExpr.requiredArgs = new ArrayList<>();
        for (BVarSymbol symbol : invokableSymbol.params) {
            if (!Symbols.isFlagOn(Flags.asMask(symbol.getFlags()), Flags.INCLUDED) ||
                    Types.getReferredType(symbol.type).tag != TypeTags.RECORD) {
                continue;
            }
            LinkedHashMap<String, BField> fields =
                    ((BRecordType) Types.getReferredType(symbol.type)).fields;
            if (fields.isEmpty()) {
                continue;
            }
            for (String field : fields.keySet()) {
                if (Types.getReferredType(fields.get(field).type).tag != TypeTags.NEVER) {
                    parameterCountForNamedArgs = parameterCountForNamedArgs - 1;
                    break;
                }
            }
        }

        
        int i = 0;
        BLangExpression vararg = null;
        boolean foundNamedArg = false;
        boolean isIncRecordAllowExtraFields = incRecordParamAllowAdditionalFields != null;
        for (BLangExpression expr : iExpr.argExprs) {
            switch (expr.getKind()) {
                case NAMED_ARGS_EXPR:
                    foundNamedArg = true;
                    BLangNamedArgsExpression namedArg = (BLangNamedArgsExpression) expr;
                    boolean isNamedArgForIncRecordParam =
                                  isNamedArgForIncRecordParam(namedArg.name.value, incRecordParamAllowAdditionalFields);
                    if (i < parameterCountForNamedArgs) {
                        if (isNamedArgForIncRecordParam) {
                            isIncRecordAllowExtraFields = false;
                        }
                        iExpr.requiredArgs.add(expr);
                    } else {
                        if (isIncRecordAllowExtraFields && !isNamedArgForIncRecordParam) {
                            iExpr.requiredArgs.add(expr);
                        } else {
                            dlog.error(expr.pos, DiagnosticErrorCode.TOO_MANY_ARGS_FUNC_CALL, iExpr.name.value);
                        }
                    }
                    i++;
                    break;
                case REST_ARGS_EXPR:
                    if (foundNamedArg) {
                        dlog.error(expr.pos, DiagnosticErrorCode.REST_ARG_DEFINED_AFTER_NAMED_ARG);
                        continue;
                    }
                    vararg = expr;
                    break;
                default: 
                    if (foundNamedArg) {
                        dlog.error(expr.pos, DiagnosticErrorCode.POSITIONAL_ARG_DEFINED_AFTER_NAMED_ARG);
                    }
                    if (i < parameterCountForPositionalArgs) {
                        iExpr.requiredArgs.add(expr);
                    } else {
                        iExpr.restArgs.add(expr);
                    }
                    i++;
                    break;
            }
        }

        return checkInvocationArgs(iExpr, paramTypes, vararg, incRecordParams,
                                    incRecordParamAllowAdditionalFields, data);
    }

Line commented on: isNamedArgForIncRecordParam(namedArg.name.value, incRecordParamAllowAdditionalFields);

Revised code:
private BType checkInvocationParam(BLangInvocation iExpr, AnalyzerData data) {
        if (Symbols.isFlagOn(iExpr.symbol.type.flags, Flags.ANY_FUNCTION)) {
            dlog.error(iExpr.pos, DiagnosticErrorCode.INVALID_FUNCTION_POINTER_INVOCATION_WITH_TYPE);
            return symTable.semanticError;
        }
        BType invocableType = Types.getReferredType(iExpr.symbol.type);
        if (invocableType.tag != TypeTags.INVOKABLE) {
            dlog.error(iExpr.pos, DiagnosticErrorCode.INVALID_FUNCTION_INVOCATION, iExpr.symbol.type);
            return symTable.noType;
        }

        BInvokableSymbol invokableSymbol = ((BInvokableSymbol) iExpr.symbol);
        List<BType> paramTypes = ((BInvokableType) invocableType).getParameterTypes();
        List<BVarSymbol> incRecordParams = new ArrayList<>();
        BVarSymbol incRecordParamAllowAdditionalFields = checkForIncRecordParamAllowAdditionalFields(invokableSymbol,
                                                                                                     incRecordParams);
        int parameterCountForPositionalArgs = paramTypes.size();
        int parameterCountForNamedArgs = parameterCountForPositionalArgs + incRecordParams.size();
        iExpr.requiredArgs = new ArrayList<>();
        for (BVarSymbol symbol : invokableSymbol.params) {
            if (!Symbols.isFlagOn(Flags.asMask(symbol.getFlags()), Flags.INCLUDED) ||
                    Types.getReferredType(symbol.type).tag != TypeTags.RECORD) {
                continue;
            }
            LinkedHashMap<String, BField> fields =
                    ((BRecordType) Types.getReferredType(symbol.type)).fields;
            if (fields.isEmpty()) {
                continue;
            }
            for (String field : fields.keySet()) {
                if (Types.getReferredType(fields.get(field).type).tag != TypeTags.NEVER) {
                    parameterCountForNamedArgs = parameterCountForNamedArgs - 1;
                    break;
                }
            }
        }

        
        int i = 0;
        BLangExpression vararg = null;
        boolean foundNamedArg = false;
        boolean incRecordAllowAdditionalFields = incRecordParamAllowAdditionalFields != null;
        for (BLangExpression expr : iExpr.argExprs) {
            switch (expr.getKind()) {
                case NAMED_ARGS_EXPR:
                    foundNamedArg = true;
                    boolean namedArgForIncRecordParam =
                                  isNamedArgForIncRecordParam(((BLangNamedArgsExpression) expr).name.value,
                                                              incRecordParamAllowAdditionalFields);
                    if (i < parameterCountForNamedArgs) {
                        if (namedArgForIncRecordParam) {
                            incRecordAllowAdditionalFields = false;
                        }
                        iExpr.requiredArgs.add(expr);
                    } else {
                        if (incRecordAllowAdditionalFields && !namedArgForIncRecordParam) {
                            iExpr.requiredArgs.add(expr);
                        } else {
                            checkTypeParamExpr(expr, new BNoType(TypeTags.NONE), iExpr.langLibInvocation, data);
                            dlog.error(expr.pos, DiagnosticErrorCode.TOO_MANY_ARGS_FUNC_CALL, iExpr.name.value);
                        }
                    }
                    i++;
                    break;
                case REST_ARGS_EXPR:
                    if (foundNamedArg) {
                        dlog.error(expr.pos, DiagnosticErrorCode.REST_ARG_DEFINED_AFTER_NAMED_ARG);
                        continue;
                    }
                    vararg = expr;
                    break;
                default: 
                    if (foundNamedArg) {
                        dlog.error(expr.pos, DiagnosticErrorCode.POSITIONAL_ARG_DEFINED_AFTER_NAMED_ARG);
                    }
                    if (i < parameterCountForPositionalArgs) {
                        if (Symbols.isFlagOn(invokableSymbol.params.get(i).flags, Flags.INCLUDED)) {
                            incRecordAllowAdditionalFields = false;
                        }
                        iExpr.requiredArgs.add(expr);
                    } else {
                        iExpr.restArgs.add(expr);
                    }
                    i++;
                    break;
            }
        }

        return checkInvocationArgs(iExpr, paramTypes, vararg, incRecordParams,
                                    incRecordParamAllowAdditionalFields, data);
    }