From: cuiweixie Date: Thu, 25 Aug 2022 06:41:23 +0000 (+0800) Subject: reflect: FuncOf support more than 50 arguments X-Git-Tag: go1.20rc1~1403 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d7a3fa120db1f8ab9e02ea8fccd0cc8699bf9382;p=gostls13.git reflect: FuncOf support more than 50 arguments Fixes #54669 Change-Id: I34cbe729d187437ddeafbaa910af6ed001b2603f Reviewed-on: https://go-review.googlesource.com/c/go/+/425461 Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Ian Lance Taylor Auto-Submit: Ian Lance Taylor --- diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index 3ba6cc2d51..37e01e0be4 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -6258,6 +6258,13 @@ func TestFuncOf(t *testing.T) { FuncOf([]Type{TypeOf(1), TypeOf(""), SliceOf(TypeOf(false))}, nil, true) shouldPanic("must be slice", func() { FuncOf([]Type{TypeOf(0), TypeOf(""), TypeOf(false)}, nil, true) }) shouldPanic("must be slice", func() { FuncOf(nil, nil, true) }) + + //testcase for #54669 + var in []Type + for i := 0; i < 51; i++ { + in = append(in, TypeOf(1)) + } + FuncOf(in, nil, false) } type B1 struct { diff --git a/src/reflect/type.go b/src/reflect/type.go index cb657905d0..443a4b258d 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -2077,9 +2077,7 @@ func FuncOf(in, out []Type, variadic bool) Type { args = append(args, t) hash = fnv1(hash, byte(t.hash>>24), byte(t.hash>>16), byte(t.hash>>8), byte(t.hash)) } - if len(args) > 50 { - panic("reflect.FuncOf does not support more than 50 arguments") - } + ft.tflag = 0 ft.hash = hash ft.inCount = uint16(len(in))