Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
scabug opened this issue Jun 4, 2011 · 4 comments
Closed
Assignees
Labels

Comments

@scabug
Copy link

scabug commented Jun 4, 2011

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.

@scabug
Copy link
Author

scabug commented Jun 4, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4671?orig=1
Reporter: hishidama
Affected Versions: 2.9.0

@scabug
Copy link
Author

scabug commented Jun 6, 2011

@dcsobral said:
Duplicate of #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.

@scabug
Copy link
Author

scabug commented Jun 20, 2011

@LilyLambda said:
Closely related to #1655, only deferring lazy behavior in this case would be damn near impossible.

@scabug
Copy link
Author

scabug commented Jul 1, 2011

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

@scabug scabug closed this as completed Jul 1, 2011
@scabug scabug added the repl label Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants