pkl
pkl copied to clipboard
`Listing.join` and `List.join` do not call `toString` override on elements
Given input
class Thing {
a: Int
b: Int
function toString(): String = "\(a):\(b)"
}
local thingListing = new Listing<Thing> {
new { a = 10; b = 20 }
new { a = 30; b = 40 }
}
local thingList = thingListing.toList()
resultListing = thingListing.join("\n")
resultList = thingList.join("\n")
The expected output is
resultListing = """
10:20
30:30
"""
resultList = """
10:20
30:30
"""
The actual output is
resultListing = """
new Thing { a = 10; b = 20 }
new Thing { a = 30; b = 40 }
"""
resultList = """
new Thing { a = 10; b = 20 }
new Thing { a = 30; b = 40 }
"""
Other instances where Pkl can convert arbitrary values to String (i.e. string interpolation) correctly call the value's toString() method.
This seems like a bug to me.
This would also be a breaking change if fixed.