@@ -19,6 +19,7 @@ import (
19
19
"encoding/json"
20
20
"fmt"
21
21
"math/big"
22
+ "reflect"
22
23
"sort"
23
24
"strings"
24
25
)
@@ -70,16 +71,11 @@ func (v *Value) UnmarshalCBOR(data []byte) error {
70
71
v .value = tmpConstr
71
72
} else {
72
73
// Fall back to standard CBOR tag parsing for our supported types
73
- var tmpTagDecode interface {}
74
+ var tmpTagDecode any
74
75
if _ , err := Decode (data , & tmpTagDecode ); err != nil {
75
76
return err
76
77
}
77
- switch tmpTagDecode .(type ) {
78
- case int , uint , int64 , uint64 , bool , big.Int , WrappedCbor , Rat , Set , Map :
79
- v .value = tmpTagDecode
80
- default :
81
- return fmt .Errorf ("unsupported CBOR tag number: %d" , tmpTag .Number )
82
- }
78
+ v .value = tmpTagDecode
83
79
}
84
80
default :
85
81
var tmpValue interface {}
@@ -132,14 +128,19 @@ func (v *Value) processMap(data []byte) (err error) {
132
128
)
133
129
}
134
130
}()
135
- tmpValue := map [Value ]Value {}
131
+ tmpValue := map [* Value ]Value {}
136
132
if _ , err = Decode (data , & tmpValue ); err != nil {
137
133
return err
138
134
}
139
135
// Extract actual value from each child value
140
- newValue := map [interface {}] interface {} {}
136
+ newValue := map [any ] any {}
141
137
for key , value := range tmpValue {
142
- newValue [key .Value ()] = value .Value ()
138
+ keyValue := key .Value ()
139
+ // Use a pointer for unhashable key types
140
+ if ! reflect .TypeOf (keyValue ).Comparable () {
141
+ keyValue = & keyValue
142
+ }
143
+ newValue [keyValue ] = value .Value ()
143
144
}
144
145
v .value = newValue
145
146
return nil
@@ -151,7 +152,7 @@ func (v *Value) processArray(data []byte) error {
151
152
return err
152
153
}
153
154
// Extract actual value from each child value
154
- newValue := []interface {} {}
155
+ newValue := []any {}
155
156
for _ , value := range tmpValue {
156
157
newValue = append (newValue , value .Value ())
157
158
}
0 commit comments