unify-byte-counts #21

Merged
sashakoshka merged 16 commits from unify-byte-counts into main 2025-10-13 08:49:49 -06:00
Showing only changes of commit cbfb513933 - Show all commits

View File

@@ -355,8 +355,12 @@ func encodeAnyMap(encoder *Encoder, value any, tag Tag) (n int, err error) {
} }
func canSet(destination reflect.Type, tag Tag) error { func canSet(destination reflect.Type, tag Tag) error {
fmt.Println("== CAN SET ====================")
fmt.Println(destination)
fmt.Println(tag)
// anything can be assigned to `any` // anything can be assigned to `any`
if isTypeAny(destination) { if isTypeAny(destination) {
fmt.Println("OK")
return nil return nil
} }
switch tag.WithoutCN() { switch tag.WithoutCN() {
@@ -387,12 +391,17 @@ func canSet(destination reflect.Type, tag Tag) error {
return errCantAssignf("cannot assign array to %v", destination) return errCantAssignf("cannot assign array to %v", destination)
} }
case KTV: case KTV:
if destination != reflect.TypeOf(dummyMap) { cantAssign :=
destination.Kind() != reflect.Map ||
destination.Key().Kind() != reflect.Uint16 ||
!isTypeAny(destination.Elem())
if cantAssign {
return errCantAssignf("cannot assign table to %v", destination) return errCantAssignf("cannot assign table to %v", destination)
} }
default: default:
return fmt.Errorf("unknown TN %d", tag.TN()) return fmt.Errorf("unknown TN %d", tag.TN())
} }
fmt.Println("OK")
return nil return nil
} }