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

scala.io.Source scala2.9 REPL wrong result when dividing into two lines

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.0
    • Fix Version/s: None
    • Component/s: Repl / Interpreter
    • Labels:
      None
    • Environment:

      Windows XP

      Description

      Scala2.9 REPL scala.io.Source
      It becomes a false result if it divides into two lines when it is one line though it is correct.

      //OK
      scala> val s = scala.io.Source.fromFile("C:/a.txt"); val r = s.getLines.toList
      s: scala.io.BufferedSource = empty iterator
      r: List[String] = List(aaa, aa)

      //NG
      scala> val s = scala.io.Source.fromFile("C:/a.txt")
      s: scala.io.BufferedSource = non-empty iterator

      scala> val r = s.getLines.toList
      r: List[String] = List()

      Scala2.8.1 is OK.

        Activity

        Hide
        Daniel Sobral added a comment -

        Duplicate of SI-4662.

        For your information, the problem is that REPL printed the iterator s, which makes getLines return empty. Work-around: don't print a BufferedSource before calling getLines on it.

        Show
        Daniel Sobral added a comment - Duplicate of SI-4662 . For your information, the problem is that REPL printed the iterator s , which makes getLines return empty. Work-around: don't print a BufferedSource before calling getLines on it.
        Hide
        Yuvi Masory added a comment -

        Closely related to SI-1655, only deferring lazy behavior in this case would be damn near impossible.

        Show
        Yuvi Masory added a comment - Closely related to SI-1655 , only deferring lazy behavior in this case would be damn near impossible.
        Hide
        Commit Message Bot added a comment -

        (extempore in r25212) Keep BufferedSource from losing buffered data when a derivative iterator
        is created via getLines. Closes #4671, #4662, no review.

        Show
        Commit Message Bot added a comment - (extempore in r25212 ) Keep BufferedSource from losing buffered data when a derivative iterator is created via getLines. Closes #4671, #4662, no review.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            hishidama
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development