Compiler should prevent methods/functions without RETURN statement - OpenEdge 11.6 Community Input - Products Enhancements - Progress Community

 OpenEdge 11.6 Community Input

Compiler should prevent methods/functions without RETURN statement

The compiler should prohibit (or at least warn about) non void methods/functions that have no RETURN statement on every possible execution path.

In Java, such code doesn't even compile.

In ABL, when you forget a RETURN x. statement, you don't get any warning, while the method always returns ?.

This check could be part of a new "strict compile" option, which should be on by default.

Comments
  • Where ever this happens in currently existing code, you technically have a bug that needs fixing.

    I would suggest that the compile should by default fail when a code path has no RETURN statement, and a startup parameter, similar to -brl, or an option on the compiler, can be provided to allow for recompiling legacy code until it can be fixed.

  • this should be included in a new "strict" compiler mode, this mode could be extended in the future with many more checks.

    For example use of legacy functions and so on.

  • +1 as we've lost hours again figuring out why a large piece of refactored code wasn't working...