I am ashamed to report this, and I'm not 100% confident it's truly bug. It cost me some pain to figure out what was happening, so it's at least recorded here for posterity;
type SC = "" | "moo"
@main def testEmptyUnion =
val start = """"""""
val pt1_read : SC = upickle.default.read[SC](start)
val pt1_write = upickle.default.write[SC](pt1_read)
println("read")
println(pt1_read)
println("Write")
println(pt1_write)
println("End")
This script prints the following;
read
""
Write
"\"\""
End
I think there are too many quotes when the empty string is written as a union. It is different to the encoding of just the empty string, so that behaviour at least is not intuitive for me. Arguably, this "read / write" operation is changing it's data and my calling program got grumpy about that, and I struggled a little to figure out why.
The empty string as a String type, seems to yield differnt.
@main def testEmpty =
val start = """"""""
val pt1_read = upickle.default.read[String](start)
println("read")
println(pt1_read)
val pt1_write = upickle.default.write[String](pt1_read)
println("Write")
println(pt1_write)
I am ashamed to report this, and I'm not 100% confident it's truly bug. It cost me some pain to figure out what was happening, so it's at least recorded here for posterity;
This script prints the following;
I think there are too many quotes when the empty string is written as a union. It is different to the encoding of just the empty string, so that behaviour at least is not intuitive for me. Arguably, this "read / write" operation is changing it's data and my calling program got grumpy about that, and I struggled a little to figure out why.
The empty string as a
String
type, seems to yield differnt.Produces