Uploaded image for project: 'Railo'
  1. Railo
  2. RAILO-2045

arrayContains() should take any data type in the second argument

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 3.3.4.003
    • Fix Version/s: 4.1.0.000, 4.0.1.000
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      <cfset st =

      {key="value"}

      >
      <cfset a = [st]>
      <cftry>
      <cfset b = arrayContains(a, st)>
      <cfcatch>
      <cfdump var="#cfcatch#">
      </cfcatch>
      <cffinally>
      <cfdump var="#variables#">
      </cffinally>
      </cftry>

      Show
      <cfset st = {key="value"} > <cfset a = [st] > <cftry> <cfset b = arrayContains(a, st)> <cfcatch> <cfdump var="#cfcatch#"> </cfcatch> <cffinally> <cfdump var="#variables#"> </cffinally> </cftry>

      Description

      (quoted from https://groups.google.com/forum/?fromgroups=#!topic/railo/Z2RJJi2kurE)

      Consider the code below in "Steps to Reproduce"

      This errors with:

      Railo 3.3.4.003 Error (expression)
      Message Can't cast Complex Object Type Struct to String
      Detail Use Build-In-Function "serialize(Struct):String" to create a String from Struct

      The problem seems to be this (from http://wiki.getrailo.org/wiki/3-1-Functions:ArrayContains):

      Arguments

      Name Type Required Position Default Description
      haystack Array Yes 1

      needle String Yes 2

      needle should not be a string, it should be anything (see http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WS2EF4F7C2-F41D-42fe-940D-B7C0212FF3D9.html).

      Cheers.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                micstriit Michael Offner
                Reporter:
                adamcameroncf Adam Cameron
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: