Function return type does not match with the actual variable returned


    This rule states that a function's return type must match the type of the variable that is actually returned. For example, if a function is declared as returning an integer, then the function must return an integer value. If a function is declared as returning a string, then the function must return a string value. If the actual return value does not match the declared return type, then the code will not compile.

Key Benefits

  • Ensures Code Quality: Ensures that code is written correctly and is of high quality by forcing developers to return the correct data type.
  • Reduces Debugging Time: Reduces the amount of time spent debugging code by catching errors early on in the development process.
  • Increases Readability: Makes code more readable by making it easier to identify what data type is being returned.
  • Improves Reusability: Improves code reusability by making it easier to use the same code in different locations without having to make changes to the return type.


Non-compliant Code Example

function integer CheckFunctionReturnType (string id, LONGLONG quantity)

Return quantity //Non compliant code

end function

Compliant Code Example

function LONGLONG CheckFunctionReturnType (string id, integer quantity)

Return quantity //Compliant code

end function
Visual Expert 2024