private DataType InferInvocationType(InvocationSyntax invocation) { // This could: // * Invoke a stand alone function // * Invoke a static function // * Invoke a method // * Invoke a function pointer var argumentTypes = invocation.Arguments.Select(InferArgumentType).ToFixedList(); InferExpressionTypeInInvocation(invocation.Callee, argumentTypes); var callee = invocation.Callee.Type; if (callee is FunctionType functionType) { foreach (var(arg, type) in invocation.Arguments.Zip(functionType.ParameterTypes)) { InsertImplicitConversionIfNeeded(ref arg.Value, type); CheckArgumentTypeCompatibility(type, arg); } return(invocation.Type = functionType.ReturnType); } // If it is unknown, we already reported an error if (callee == DataType.Unknown) { return(invocation.Type = DataType.Unknown); } diagnostics.Add(TypeError.MustBeCallable(file, invocation.Callee)); return(invocation.Type = DataType.Unknown); }