Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CF2016 bug in update 12

New Here ,
Oct 10, 2019 Oct 10, 2019

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>

 

83
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources