diff --git a/common/types/list.go b/common/types/list.go index d4932b4a..06f48dde 100644 --- a/common/types/list.go +++ b/common/types/list.go @@ -190,7 +190,13 @@ func (l *baseList) ConvertToNative(typeDesc reflect.Type) (any, error) { // Allow the element ConvertToNative() function to determine whether conversion is possible. otherElemType := typeDesc.Elem() elemCount := l.size - nativeList := reflect.MakeSlice(typeDesc, elemCount, elemCount) + var nativeList reflect.Value + if typeDesc.Kind() == reflect.Array { + nativeList = reflect.New(reflect.ArrayOf(elemCount, typeDesc)).Elem().Index(0) + } else { + nativeList = reflect.MakeSlice(typeDesc, elemCount, elemCount) + + } for i := 0; i < elemCount; i++ { elem := l.NativeToValue(l.get(i)) nativeElemVal, err := elem.ConvertToNative(otherElemType) diff --git a/ext/native_test.go b/ext/native_test.go index 2641ad72..27479cfc 100644 --- a/ext/native_test.go +++ b/ext/native_test.go @@ -62,6 +62,12 @@ func TestNativeTypes(t *testing.T) { NestedMapVal: {42: true}, }, ], + ArrayVal: [ + ext.TestNestedType{ + NestedListVal:['goodbye', 'cruel', 'world'], + NestedMapVal: {42: true}, + }, + ], MapVal: {'map-key': ext.TestAllTypes{BoolVal: true}}, CustomSliceVal: [ext.TestNestedSliceType{Value: 'none'}], CustomMapVal: {'even': ext.TestMapVal{Value: 'more'}}, @@ -85,6 +91,10 @@ func TestNativeTypes(t *testing.T) { NestedMapVal: map[int64]bool{42: true}, }, }, + ArrayVal: [1]*TestNestedType{{ + NestedListVal: []string{"goodbye", "cruel", "world"}, + NestedMapVal: map[int64]bool{42: true}, + }}, MapVal: map[string]TestAllTypes{"map-key": {BoolVal: true}}, CustomSliceVal: []TestNestedSliceType{{Value: "none"}}, CustomMapVal: map[string]TestMapVal{"even": {Value: "more"}}, @@ -688,6 +698,7 @@ type TestAllTypes struct { Uint32Val uint32 Uint64Val uint64 ListVal []*TestNestedType + ArrayVal [1]*TestNestedType MapVal map[string]TestAllTypes PbVal *proto3pb.TestAllTypes CustomSliceVal []TestNestedSliceType