Skip to content

Commit 2693971

Browse files
zhiqiangxublakehhuynh
authored andcommitted
accounts/abi: fix set function (ethereum#25477)
* accounts/abi: fix set function * don't break things * update test
1 parent d9c73d6 commit 2693971

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

accounts/abi/reflect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func mustArrayToByteSlice(value reflect.Value) reflect.Value {
9999
func set(dst, src reflect.Value) error {
100100
dstType, srcType := dst.Type(), src.Type()
101101
switch {
102-
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid():
102+
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid() && (dst.Elem().Type().Kind() == reflect.Ptr || dst.Elem().CanSet()):
103103
return set(dst.Elem(), src)
104104
case dstType.Kind() == reflect.Ptr && dstType.Elem() != reflect.TypeOf(big.Int{}):
105105
return set(dst.Elem(), src)

accounts/abi/unpack_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ func TestMethodMultiReturn(t *testing.T) {
352352
&[]interface{}{&expected.Int, &expected.String},
353353
"",
354354
"Can unpack into a slice",
355+
}, {
356+
&[]interface{}{&bigint, ""},
357+
&[]interface{}{&expected.Int, expected.String},
358+
"",
359+
"Can unpack into a slice without indirection",
355360
}, {
356361
&[2]interface{}{&bigint, new(string)},
357362
&[2]interface{}{&expected.Int, &expected.String},

0 commit comments

Comments
 (0)