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

Bug with scoping inside iterator functions

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Rejected
    • Affects Version/s: 4.2.0.006
    • Fix Version/s: None
    • Labels:
      None

      Description

      See this code:

      iterations = 0;
      numbers = [1,2,3,4];
      numbers.each(function(v,i){
      	iterations++;
      	writeOutput("#iterations#<br>");
      });
      

      And this output:

      1
      1
      1
      1
      

      It should be:

      1
      2
      3
      4
      

      Note: if I change it to variables.iterations++ it works fine. However I should not need to do this.

      Also, if it's not checking the variables scope, it should *error* on iterations++ as there is no local variable of that name at the point in time I am trying to increment it.

      Verified as being broke on both each() and sort() method. Have not tested others.


      Adam

        Gliffy Diagrams

          Attachments

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: