Skip to content

Commit

Permalink
accounts/abi: fix set function (ethereum#25477)
Browse files Browse the repository at this point in the history
* accounts/abi: fix set function

* don't break things

* update test
  • Loading branch information
zhiqiangxu authored and blakehhuynh committed Oct 7, 2022
1 parent db22876 commit a354ad7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion accounts/abi/reflect.go
Expand Up @@ -99,7 +99,7 @@ func mustArrayToByteSlice(value reflect.Value) reflect.Value {
func set(dst, src reflect.Value) error {
dstType, srcType := dst.Type(), src.Type()
switch {
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid():
case dstType.Kind() == reflect.Interface && dst.Elem().IsValid() && (dst.Elem().Type().Kind() == reflect.Ptr || dst.Elem().CanSet()):
return set(dst.Elem(), src)
case dstType.Kind() == reflect.Ptr && dstType.Elem() != reflect.TypeOf(big.Int{}):
return set(dst.Elem(), src)
Expand Down
5 changes: 5 additions & 0 deletions accounts/abi/unpack_test.go
Expand Up @@ -352,6 +352,11 @@ func TestMethodMultiReturn(t *testing.T) {
&[]interface{}{&expected.Int, &expected.String},
"",
"Can unpack into a slice",
}, {
&[]interface{}{&bigint, ""},
&[]interface{}{&expected.Int, expected.String},
"",
"Can unpack into a slice without indirection",
}, {
&[2]interface{}{&bigint, new(string)},
&[2]interface{}{&expected.Int, &expected.String},
Expand Down

0 comments on commit a354ad7

Please sign in to comment.