Skip to main content
October 10, 2019
Question

CF2016 bug in update 12

  • October 10, 2019
  • 0 replies
  • 99 views

when return implicitly declared array from inside a CFIF with a CFELSE will cause an incorrect return value.

in the code below, function test4 will return 0,0 on CF2016 with applied update 12. other server with applied update 6 returns 2,0. function test3 is identical except it has no else statement, works the same on both.

 

<!--- works as expected --->
<cffunction name="test3">
    <cfargument name="a1" type="string" required="true">

    <cfset var x = 0>
    <cfset var y = 0>

    <cfif a1 gt 1>
        <cfset x += a1>
        <cfreturn [ x, y, "", "" ]>
    </cfif>

    <cfreturn [ x, y, "", "" ]>  
</cffunction>

<!--- doesnt work --->
<cffunction name="test4">
    <cfargument name="a1" type="string" required="true">

    <cfset var x = 0>
    <cfset var y = 0>

    <cfif a1 gt 1>
        <cfset x += a1>
        <cfreturn [ x, y, "", "" ]>
    <cfelse>
        <cfset x += a1>
    </cfif>

    <cfreturn [ x, y, "", "" ]>  
</cffunction>


<cfset x = test3(2)>
<cfoutput>#x[1]# #x[2]# #x[3]# #x[4]#</cfoutput>

<br>

<cfset x = test4(2)>
<cfoutput>#x[1]# #x[2]# #x[3]# #x[4]#</cfoutput>

<br>

<cfset x = test4(1)>
<cfoutput>#x[1]# #x[2]# #x[3]# #x[4]#</cfoutput>

 

    This topic has been closed for replies.