tape: canAssign now reports true for named table types
This commit is contained in:
parent
f10327356e
commit
cbfb513933
@ -355,8 +355,12 @@ func encodeAnyMap(encoder *Encoder, value any, tag Tag) (n int, err 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`
|
||||
if isTypeAny(destination) {
|
||||
fmt.Println("OK")
|
||||
return nil
|
||||
}
|
||||
switch tag.WithoutCN() {
|
||||
@ -387,12 +391,17 @@ func canSet(destination reflect.Type, tag Tag) error {
|
||||
return errCantAssignf("cannot assign array to %v", destination)
|
||||
}
|
||||
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)
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unknown TN %d", tag.TN())
|
||||
}
|
||||
fmt.Println("OK")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user