We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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> Nil.mkString(",") val res0: String = "" scala> fansi.Str.join(Nil, "") val res1: fansi.Str = scala> fansi.Str.join(Nil, ",") java.lang.NegativeArraySizeException: -1 at fansi.Str$.join(Fansi.scala:370) ... 66 elided
I'm not sure if it's a bug, but allowing (Nil, ",") sounds more consistent.
Scala 3.1.3, fansi 0.3.1
The text was updated successfully, but these errors were encountered:
Same thing with Scala 2.13.10:
val s2 = Vector[fansi.Str](fansi.Color.Blue("blue")) println("nonEmpty: " + fansi.Str.join(s2, ", ").render) val s3 = Vector[fansi.Str]() println("empty: " + fansi.Str.join(s3, ", ").render)
Running it:
nonEmpty: blue [error] java.lang.NegativeArraySizeException: -2 [error] at fansi.Str$.join(Fansi.scala:370)
Sorry, something went wrong.
Yup, lines 368 and following of Fansi.scala:
def join(args: Iterable[Str], sep: fansi.Str = fansi.Str("")) = { val length = args.iterator.map(_.length + sep.length).sum - sep.length val chars = new Array[Char](length)
If the args iterable is empty, length becomes negative by the length of sep, which causes a problem in the next line.
No branches or pull requests
I'm not sure if it's a bug, but allowing (Nil, ",") sounds more consistent.
Scala 3.1.3, fansi 0.3.1
The text was updated successfully, but these errors were encountered: