diff --git a/error_templates/java/missing_return_error.go b/error_templates/java/missing_return_error.go index 35b5b37..6e79ca6 100644 --- a/error_templates/java/missing_return_error.go +++ b/error_templates/java/missing_return_error.go @@ -62,7 +62,7 @@ var MissingReturnError = lib.ErrorTemplate{ // nearest sym will be at the last valueToReturn := getDefaultValueForType(expectedTypeSym) if len(symbolsForReturn) != 0 { - nearestSym := symbolsForReturn[len(symbolsForReturn)-1] + nearestSym := symbolsForReturn[0] valueToReturn = nearestSym.Name() } diff --git a/error_templates/java/test_files/missing_return_error/test.txt b/error_templates/java/test_files/missing_return_error/test.txt index aba927e..6718a10 100644 --- a/error_templates/java/test_files/missing_return_error/test.txt +++ b/error_templates/java/test_files/missing_return_error/test.txt @@ -23,7 +23,7 @@ Since the `addNumbers` method is declared to return an `int`, you need to provid public class MissingReturn { public int addNumbers(int a, int b) { // Missing return statement -+ return b; ++ return a; } ```