You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would you mind elaborating on why unsigneds can't be supported?
I'd recommend making a new GitHub issue 'support unsigned ints' (I could make the issue if you like) and adding the link in the source code, then it's easier to track and follow progress.
@Serializable
data class UnsingedIntegers(
val s: UInt,
val b: UByte,
val i: UInt,
val l: ULong,
)
var testUnsigned = """
s = 5
b = 5
i = 5
l = 5
""".trimIndent()
println(Toml.decodeFromString<UnsingedIntegers>(testUnsigned))
Will cause error:
Index -1 out of bounds for length 4
java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 4
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266)
at java.base/java.util.Objects.checkIndex(Objects.java:359)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at com.akuleshov7.ktoml.decoders.TomlMainDecoder.getCurrentNode(TomlMainDecoder.kt:81)
I think that UInt.MAX_VALUE is -1, so the current way of validating won't work for unsigned nums.
I'd prefer refracting the logic to match how KsX JSON does it #171 (comment)
Actually the logic should be the same: parsing to the biggest available type (ULong) and checking bounds: UInt.MAX_VALUE.toULong() = 4294967295
I think that with floating-point numbers KsX approach is not so good, as I have described in #175 (comment) . One year ago I was fixing Double behaviour in Kotlin 1.7 and to my mind there can be such pitfall like I describe...
Would you mind elaborating on why unsigneds can't be supported?
I'd recommend making a new GitHub issue 'support unsigned ints' (I could make the issue if you like) and adding the link in the source code, then it's easier to track and follow progress.
Originally posted by @aSemy in #171 (comment)
The text was updated successfully, but these errors were encountered: