public override void ExitMethodDeclaration(MethodDeclaration methodDeclaration) { foreach (var duplicates in methodDeclaration.GenericTypeDeclarations.GetDuplicatesBy(x => x.Name)) { Errors.Add(new CompilationError(methodDeclaration.Context, "Duplicate generic declarations: " + duplicates.Key)); } foreach (var duplicates in methodDeclaration.Variables.GetDuplicatesBy(x => x.Name)) { Errors.Add(new CompilationError(methodDeclaration.Context, "Duplicate parameter declarations: " + duplicates.Key)); } bool foundParameterWithDefaultValue = false; foreach (var parameter in methodDeclaration.Variables) { if (parameter.InitExpression != null) { foundParameterWithDefaultValue = true; } else if (foundParameterWithDefaultValue) { Errors.Add(new CompilationError(methodDeclaration.Context, "Default parameters must be the last parameters in the method.")); break; } } if (!(methodDeclaration.ReturnType is VoidType || methodDeclaration.ReturnType == null && methodDeclaration.AllDescendantsAndSelf().OfType <ReturnStatement>().All(x => x.Value == null)) && !DoAllPathsReturnAValue(methodDeclaration.Body)) { Errors.Add(new CompilationError(methodDeclaration.Context, "Not all paths return a value")); } }