From d7a3fa120db1f8ab9e02ea8fccd0cc8699bf9382 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Thu, 25 Aug 2022 14:41:23 +0800 Subject: [PATCH] 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 --- src/reflect/all_test.go | 7 +++++++ src/reflect/type.go | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) 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)) -- 2.50.0