aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorcuiweixie <cuiweixie@gmail.com>2022-08-25 14:41:23 +0800
committerGopher Robot <gobot@golang.org>2022-08-26 14:32:13 +0000
commitd7a3fa120db1f8ab9e02ea8fccd0cc8699bf9382 (patch)
treeb44775fe364eda93fc13ce8e7dad410b5d9c4c5f /src
parent2eba2ff8a1572d7fcba65a5f9d54f73e307a0054 (diff)
downloadgo-d7a3fa120db1f8ab9e02ea8fccd0cc8699bf9382.tar.xz
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 <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/reflect/all_test.go7
-rw-r--r--src/reflect/type.go4
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))