Require-return-values compiler option
- Last Updated: January 22, 2026
- 4 minute read
- OpenEdge
- Version 12.8
- Documentation
The require-return-values compiler option performs static analysis to verify
that all logical code paths in ABL user-defined functions, non-VOID methods, and
property getters include RETURN
value statements. This helps developers to identify missing
RETURN value statements during compilation,
reducing the chance of runtime errors and improving overall code reliability. Omitting a
RETURN
value may result in unexpected behavior and make debugging more
difficult. Using this option during development can highlight potential issues before
they become runtime errors, and it can also assist in troubleshooting by revealing
fragile code that may not behave as intended.
Enabling the option and identifying violations
To enable the feature, use the require-return-values compiler option. For information on enabling
compiler options, see Set compiler options.
|
The message identifies the name of the user-defined function,
method, or property getter with the violation. It does not identify which path or
line is missing the RETURN
value statement. You need to examine your code
to determine how to make the appropriate fixes.
User-defined function, non-VOID method, or property getter block
If there are no control flow statements within the user-defined
function, non-VOID method, or property getter, then the main block of the
user-defined function, non-VOID method, or property getter requires a RETURN
value statement. The following example shows a
user-defined function that is not compliant with the require-return-values compiler option:
|
Add a RETURN
value statement to clear the warning/error, as
shown in the following example:
|
As long as the user-defined function, non-VOID method, or property getter
ends with a RETURN
value statement, then the code is compliant. If
it does not end with a RETURN
value statement, then you must make sure all
other code paths are compliant.
Verifying all other code paths provide a RETURN
value statement involves control flow analysis
of ABL programs.
Verifying other code paths are compliant
As stated previously, you simply need to end each user-defined
function, non-VOID method, or property getter with a RETURN
value statement in order to make your code
compliant. However, if this is not desired, then you can add RETURN
value statements to other constructs. The
following sections describe different statements that alter the flow from within ABL
and how the require-return-values compiler option
affects them. Before and after code examples are shown, along with information on
how to make the code compliant. The assumption is that the containing user-defined
function, method, or property getter does not end with a RETURN
value statement, so other statements and blocks
must be made compliant instead.
IF…THEN…ELSE statement
In an IF...THEN...ELSE statement, both the
IF and ELSE portions require a RETURN
value statement. Having one within either, but
not both, never satisfies the require-return-values option. If you only have an IF clause, then you must add an ELSE clause and include a RETURN
value statement for both.
|
|
CASE statement
In a CASE statement, there must be an OTHERWISE clause that includes a RETURN
value statement, and all WHEN..THEN clauses must also contain a RETURN
value statement.
|
|
Nested control flow statements
Control flow statements can appear within each other. As long as
each inner statement or block is compliant, then the outer statement or block is
also compliant. To satisfy the require-return-values compiler option, it must be the case that there
are no statements after the block.
Limitations of control flow and exception handling
The require-return-values compiler option performs static control flow
analysis. It does not evaluate runtime conditions or rely on exception handling. As
a result:
CATCHandFINALLYblocks do not satisfy the requirement.- A
THROWstatement at the end of a method is not considered a valid substitute for aRETURNstatement.To resolve the compiler warning, you must include a
RETURN valuestatement in all code paths, even if some paths end inTHROW. For example:... UNDO, THROW NEW Exceptions.ERecordNotFound("Record not found"). RETURN "". /* Unreachable but required for compiler */ END METHOD.
|
ELSE RETURN
value or a fallback RETURN
value statement to make sure that all logical
paths return a value.By requiring explicit RETURN value statements in
all code paths, the require-return-values compiler option promotes
predictable behavior and helps reduce the likelihood of runtime errors caused by
missing return values.