MSIR.0789 Implied return not valid for methods that return a value

From m204wiki
(Redirected from MSIR.0789)
Jump to navigation Jump to search

A code path analysis of a Function or property Get method has determined that it is possible to get to the end of the method without executing a Return statement and so have to do an implied return. But these methods require a return value, and there can be no return value on an implied return. If it is felt that the compiler is in error and, in fact, an implied return should never be required, contact Technical Support with the contents of the method in question.

Note that the compiler can't make data-dependent decisions about what code might or might not be executed. For example, in the following:

function genderString is string len 16 if %sex eq 'M' then return 'male' elseif %sex eq 'F' then return 'female' end if end subroutine

You might "know" that %sex will always be either "M" or "F", but the compiler really has no way of knowing this. You can restructure the code to make this clear to the compiler and avoid the MSIR.0789 message:

function genderString is string len 16 if %sex eq 'M' then return 'male' else return 'female' end if end subroutine

Another way to restructure to accomplish the same thing is:

function genderString is string len 16 if %sex eq 'M' then return 'male' end if return 'female' end subroutine

It might be a good idea to add an assertion that validates our assumption that %sex is always "M" or "F":

function genderString is string len 16 if %sex eq 'M' then return 'male' end if assert %sex eq 'F' return 'female' end subroutine


Message attributes:

RETCODEO=0Sets online return code
RETCODEB=4Sets batch (single user) return code
CLASS=EError class; the message can be suppressed with the X'04' bit setting of the MSGCTL parameter
AUDITERWrites the message with line type ER to the audit trail
COUNTIncrements the error count (ERCNT) parameter
ECHODisplays the line that caused the error

Back to list of messages