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

Half-exclusive range with int value on left and short value on right always contains a single element

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-beta-1, 1.6-beta-2
    • 1.6-rc-1, 1.7-beta-1
    • None
    • None
    • Ubuntu amd64. Java 1.6.0_07-b06.

    Description

      Running the code

      short upper = 4
      println (0..<upper)
      

      results in [0] in Groovy 1.6. With Groovy 1.5.6, this resulted in [0, 1, 2, 3].

      It doesn't seem to matter what values are used on the left and right hand side of the ranges. As long as the left hand value is an int and the right hand value is a short, the range always contains a single element containing the value of the int.

      This only affects half-exclusive ranges. The following code correctly returns [0, 1, 2, 3, 4] with Groovy 1.6.

      short upper = 4
      println (0..upper)
      

      Attachments

        Activity

          People

            paulk Paul King
            nigel.charman Nigel Charman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: