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

Stream toString returns unexpected result #9219

Closed
scabug opened this issue Mar 12, 2015 · 4 comments
Closed

Stream toString returns unexpected result #9219

scabug opened this issue Mar 12, 2015 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Mar 12, 2015

  val s = Stream.from(1)
  s.take(2).foreach(_ => ())
  println(s)   // prints  Stream(1, 1, ?) (should be Stream(1, 2, ?), as it is in Scala 2.11.5)

  val s = Stream.from(1)
  s.take(2).foreach(_ => ())
  s.tail.head  // prints 2, which is correct

A larger example: https://gist.github.com/tabrez/810d82308ff515de7bdc

Let me know if I need to do any corrections or if this is a duplicate(searched but found no similar issue reported).

@scabug
Copy link
Author

scabug commented Mar 12, 2015

Imported From: https://issues.scala-lang.org/browse/SI-9219?orig=1
Reporter: Tabrez Iqbal (tabrez)
Affected Versions: 2.11.6

@scabug
Copy link
Author

scabug commented Mar 12, 2015

@Ichoran said:
It's older than 2.11.6. 2.11.5 shows the same behavior in my hands. Also, there is an off-by-one error:

val s = Stream.from(1)
s.take(4).force
s   // Prints Stream(1, 2, 3, ?) even though 4 has been evaluated

@scabug
Copy link
Author

scabug commented Mar 13, 2015

Tabrez Iqbal (tabrez) said (edited on Mar 13, 2015 1:54:24 AM UTC):
A Scala community member on #scala/freenode told me it works fine on Scala 2.10 and Scala 2.11.5, probably they made a mistake about 2.11.5 version. I checked on Simply Scala and I was getting the expected correct result. (http://www.simplyscala.com/)

My bigger example also confirms off-by-one error.

@scabug
Copy link
Author

scabug commented Mar 14, 2015

@khernyo said:
pull request: scala/scala#4381

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants