-
Notifications
You must be signed in to change notification settings - Fork 21
Iterator behavior different in Scala 2.13.8 and Scala 3.1.1 #12552
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
Comments
Scala 3 uses the Scala 2 standard library but can lag, so it won't necessarily see the latest fixes. The rule not to reuse iterators is hard and fast. Edit: I see you decided to use only |
Oh good call, that does seem like a possible cause — 3.1.1 uses the 2.13.6 standard library. (The 2.13.8 upgrade has been merged but it's not clear to me yet if it will make a 3.1.x release or be held for 3.2.) A bunch of collections changes landed in 2.13.7 (and a few more in 2.13.8). @JD557 Can you try it with 2.13.6 and let us know? |
duh... it'll be in 3.1.2. I should have thought to check this:
|
Indeed, 2.13.6 passes the tests. Closing this then. |
Reproduction steps
Unfortunately, I couldn't minimize this bug, but I can point to some relevant commits:
On JD557/minart@5cf7dc8, running
sbt +2.13.8 imageJVM/test
will fail, whilesbt +3.1.1 imageJVM/test
will succeed. Simply reimplementing some operations to use next/hasNext fixed the problem.Scala version: 2.13.8 and 3.1.1 (not sure which one has the "bug")
Problem
It appears that (sometimes) on 2.13.8 calling
take(n).toArray
multiple times can return an empty array (similar to what happens onVector.iterator
).OTOH, on 3.1.1, calling
take(n).toArray
multiple times seems to work asList.iterator
, and will just keep on iterating.I understand that "calling
take(n).toArray
multiple times" is undefined behavior, but since the stdlib is the same, I expected the code to have the same undefined behavior on both compiler versionsThe text was updated successfully, but these errors were encountered: