]> Cypherpunks repositories - gostls13.git/commitdiff
reflect: document Call/CallSlice panic when v is unexported field
authorqiulaidongfeng <2645477756@qq.com>
Sat, 26 Jul 2025 05:44:12 +0000 (13:44 +0800)
committerCherry Mui <cherryyz@google.com>
Mon, 29 Dec 2025 20:45:33 +0000 (12:45 -0800)
Fixes #74377

Change-Id: I250d67ef2a4bf4dac939be669eeaf1091523ac06
Reviewed-on: https://go-review.googlesource.com/c/go/+/690617
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/reflect/value.go

index 7f0ec2a397a3c4fb8458d81dd1bd7f7a8fccb83a..8c8acbaa9abdeb1ded8db01ef7d8cbbd5a9bf4c5 100644 (file)
@@ -362,6 +362,7 @@ func (v Value) CanSet() bool {
 // type of the function's corresponding input parameter.
 // If v is a variadic function, Call creates the variadic slice parameter
 // itself, copying in the corresponding values.
+// It panics if the Value was obtained by accessing unexported struct fields.
 func (v Value) Call(in []Value) []Value {
        v.mustBe(Func)
        v.mustBeExported()
@@ -375,6 +376,7 @@ func (v Value) Call(in []Value) []Value {
 // It returns the output results as Values.
 // As in Go, each input argument must be assignable to the
 // type of the function's corresponding input parameter.
+// It panics if the Value was obtained by accessing unexported struct fields.
 func (v Value) CallSlice(in []Value) []Value {
        v.mustBe(Func)
        v.mustBeExported()