Scala Programming Language
  1. Scala Programming Language
  2. SI-7432

Range.min should throw NoSuchElementException on empty range

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.1
    • Fix Version/s: Scala 2.11.0-M3
    • Component/s: Collections
    • Labels:
      None

      Description

      Welcome to Scala version 2.10.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_17).
      Type in expressions to have them evaluated.
      Type :help for more information.
      
      scala> val range = 1000 until 1000
      range: scala.collection.immutable.Range = Range()
      
      scala> range.max
      java.util.NoSuchElementException
      
      scala> range.min
      res1: Int = 1000
      
      scala> range.par.min
      java.util.NoSuchElementException: None.get
      
      scala> range.par.max
      java.util.NoSuchElementException: None.get
      

        Activity

        Hide
        Eugene Vigdorchik added a comment -

        Symmetric problem with Range.max:

        scala> val r = new Range(10,10, -1)
        r: scala.collection.immutable.Range = Range()

        scala> r.min
        java.util.NoSuchElementException

        scala> r.max
        res1: Int = 10

        Show
        Eugene Vigdorchik added a comment - Symmetric problem with Range.max: scala> val r = new Range(10,10, -1) r: scala.collection.immutable.Range = Range() scala> r.min java.util.NoSuchElementException scala> r.max res1: Int = 10
        Hide
        Eugene Vigdorchik added a comment -

        This has been fixed in 7f29f8512d4975cf3a5a0b536a8910e4e3b4316b

        Show
        Eugene Vigdorchik added a comment - This has been fixed in 7f29f8512d4975cf3a5a0b536a8910e4e3b4316b

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Dmitry Petrashko
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development