amnaredo / test

0 stars 0 forks source link

Datastructures of mixed types are not printed correctly (0.4.3) #201

Open amnaredo opened 2 years ago

amnaredo commented 2 years ago

scala> pprint.stringify(List("asdf", "asdf")) res0: String = List("asdf", "asdf")

scala> pprint.stringify(List("asdf", "asdf", 1)) res1: String = List(asdf, asdf, 1)

scala> pprint.pprintln(List("asdf", "asdf", 1)) List(asdf, asdf, 1)

scala> pprint.pprintln(List("asdf", "asdf")) List("asdf", "asdf") ID: 189 Original Author: mduszyk

amnaredo commented 2 years ago

This is an unavoidable limitation of pprint; the typeclass derivation that it does needs to know the types of the contents statically in order to print it, so anything that's a List[Any] is going to fall back to the default PPrint[Any] for each item of the list, which is just .toString Original Author: lihaoyi