-
Notifications
You must be signed in to change notification settings - Fork 1.1k
REPL attempts infinite iterable toString #11004
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
It seems that this is because the call to def inner(arg: Any): String = arg match {
case null => "null"
case "" => "\"\""
case x: String => if (x.head.isWhitespace || x.last.isWhitespace) "\"" + x + "\"" else x
case x if useOwnToString(x) => x.toString // *** HERE this case matches, we never get to Iterable[_] below
case x: AnyRef if isArray(x) => arrayToString(x)
case x: scala.collection.Map[_, _] => x.iterator.take(maxElements).map(mapInner).mkString(x.collectionClassName + "(", ", ", ")")
case x: Iterable[_] => x.iterator.take(maxElements).map(inner).mkString(x.collectionClassName + "(", ", ", ")")
case x: Product1[_] if isTuple(x) => "(" + inner(x._1) + ",)"
case x: Product if isTuple(x) => x.productIterator.map(inner).mkString("(", ",", ")")
case x => x.toString
} |
Thanks, I totally forgot this ticket. Probably the events of Jan 6 erased my memory. |
Ref: scala/bug#3710 It seems that the logic is intended, in part, to prevent infinite traversal, and here is having the opposite effect. |
Thanks for tracking that down. The best part is
So the real bug is that a zero was lost at some point. |
I returned to this because the Scala 3 REPL currently (recently) asks for both a bounded and unbounded string result from In this case, indeed, custom Recently, I wondered if there is a use case for I will close this and bounce it back to the Scala 2 ticket. |
Minimized code
Output
Expectation
I might want to use that iterable.
This is a transfer of scala/bug#11785 which was not previously resolved.
The text was updated successfully, but these errors were encountered: