Our website uses cookies to enhance your browsing experience.
Accept
to the top

Webinar: Let's make a programming language. Lexer - 29.04

>
>
>
V8012. A function always returns the...
menu mobile close menu
Additional information
toggle menu Contents

V8012. A function always returns the same value. Consider inspecting the program's logic.

Apr 03 2026

The analyzer detected a function that returns the same value on all execution paths. Such code is suspicious and may indicate an error. Most likely, the function should return different values.

The example:

func IsEven(a int) bool {
  if a % 2 == 1 {
    return false
  }
  return false
}

The IsEven function always returns false for any passed arguments. To fix this error, the return values need to be changed.

The fixed code version:

func IsEven(a int) bool {
  if a % 2 == 1 {
    return false
  }
  return true
}

After the fix, the code can be simplified:

func IsEven(a int) bool {
  return a % 2 == 0
}