any-type #20

Merged
sashakoshka merged 18 commits from any-type into main 2025-10-12 11:03:57 -06:00
Showing only changes of commit ef3f5cf4bb - Show all commits

View File

@ -240,8 +240,16 @@ func decodeAnyOrError(decoder *Decoder, destination reflect.Value, tag Tag) (n i
if length > uint64(MaxStructureLength) {
return 0, ErrTooLong
}
lengthCast, err := Uint64ToIntSafe(length)
if err != nil { return n, err }
if isTypeAny(destination.Type()) {
// need a skeleton value if we are assigning to any.
value := reflect.MakeMapWithSize(reflect.TypeOf(dummyMap), lengthCast)
destination.Set(value)
destination = value
}
destination.Clear()
for _ = range length {
for _ = range lengthCast {
key, nn, err := decoder.ReadUint16()
n += nn; if err != nil { return n, err }
itemTag, nn, err := decoder.ReadTag()