From b9c31a8102d1f90fb2c6bcf75929b31f3239a64c Mon Sep 17 00:00:00 2001 From: Ned Palacios Date: Thu, 1 Feb 2024 22:17:52 +0800 Subject: [PATCH] fix: output mismatch in missing return error --- error_templates/java/missing_return_error.go | 2 +- error_templates/java/test_files/missing_return_error/test.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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; } ```