From b174015319c4bd1040518231ba54f6996ffbbb92 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Fri, 27 Jun 2025 14:02:38 -0400 Subject: [PATCH] tape: Fix KTV decoding not recognizing the `any` type --- tape/dynamic.go | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/tape/dynamic.go b/tape/dynamic.go index e2b1b86..c0e5301 100644 --- a/tape/dynamic.go +++ b/tape/dynamic.go @@ -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: ( )* 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)