MSIR.0789 Implied return not valid for methods that return a value: Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
(Automatically generated page update)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
A code path analysis of a <tt>Function</tt> or property <tt>Get</tt> method has determined that it is possible to get to the end of the method without executing a <tt>return</tt> statement and so have to do an implied return. But these methods require a return value and, of course, 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 [[Contacting Rocket Software Technical Support|Technical Support]] technical support with the contents of the method in question.  
A code path analysis of a <var>Function</var> or property <var>Get</var> method has determined that it is possible to get to the end of the method without executing a <var>Return</var> 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 [[Contacting Rocket Software Technical Support|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:
Note that the compiler can't make data-dependent decisions about what code might or might not be executed. For example, in the following:
Line 35: Line 35:
end subroutine</p>
end subroutine</p>


[[Category:Sirius Mods messages]]
{{Template:MSIR.0789 footer}}
[[Category:MSIR.0600 - MSIR.0799]]

Latest revision as of 23:34, 3 March 2017

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