tape: Fix KTV decoding not recognizing the any
type
This commit is contained in:
parent
e16fec3a81
commit
b174015319
@ -69,7 +69,7 @@ func DecodeAny(decoder *Decoder, destination any, tag Tag) (n int, err error) {
|
||||
func decodeAny(decoder *Decoder, destination reflect.Value, tag Tag) (n int, err error) {
|
||||
errWrongDestinationType := func(expected string) error {
|
||||
return fmt.Errorf(
|
||||
"expected %s destination, not %v",
|
||||
"expected &%s destination, not %v",
|
||||
expected, destination)
|
||||
}
|
||||
|
||||
@ -138,14 +138,8 @@ func decodeAny(decoder *Decoder, destination reflect.Value, tag Tag) (n int, err
|
||||
case KTV:
|
||||
// KTV: <length: UN> (<key: U16> <tag: Tag> <value>)*
|
||||
table := destination.Elem()
|
||||
if table.Kind() != reflect.Map {
|
||||
return n, errWrongDestinationType("map")
|
||||
}
|
||||
typ := table.Type()
|
||||
if typ.Key().Kind() != reflect.Uint16 {
|
||||
return n, errWrongDestinationType("map[uint16]")
|
||||
}
|
||||
if typ.Elem() != reflect.TypeOf(any(nil)) {
|
||||
var dummyMap map[uint16] any
|
||||
if table.Type() != reflect.TypeOf(dummyMap) {
|
||||
return n, errWrongDestinationType("map[uint16] any")
|
||||
}
|
||||
length, nn, err := decoder.ReadUintN(tag.CN() - 1)
|
||||
|
Loading…
Reference in New Issue
Block a user