Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9969

Use of a negative range with Long values results in reversed sequence

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 2.5.12, 2.5.14
    • Fix Version/s: None
    • Component/s: groovy-runtime
    • Labels:
      None

      Description

      Use of long values when describing an array range results in a reserved result when it should not.

      For example, the following is true in 2.5.11 and false starting in 2.5.12:

      [1L, 2L, 3L, 4L, 5L, 6L][(2L .. -2L)] == [3L, 4L, 5L]
      

      The following however is true in all versions of 2.5:

      [1L, 2L, 3L, 4L, 5L, 6L][(2 .. -2)] == [3L, 4L, 5L]
      

      I believe this bug was introduced in the fix for https://issues.apache.org/jira/browse/GROOVY-8966. The NumberRange produced reverses the from and to resulting in the reversed sequence.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              sfitts Sean Fitts
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: