From: qiulaidongfeng <2645477756@qq.com> Date: Sat, 26 Jul 2025 05:44:12 +0000 (+0800) Subject: reflect: document Call/CallSlice panic when v is unexported field X-Git-Tag: go1.26rc2~7^2~22 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=08369369e5a4b27d8f6d21ea571ea5027b9a2b46;p=gostls13.git reflect: document Call/CallSlice panic when v is unexported field Fixes #74377 Change-Id: I250d67ef2a4bf4dac939be669eeaf1091523ac06 Reviewed-on: https://go-review.googlesource.com/c/go/+/690617 LUCI-TryBot-Result: Go LUCI Reviewed-by: Roland Shoemaker Reviewed-by: Cherry Mui --- diff --git a/src/reflect/value.go b/src/reflect/value.go index 7f0ec2a397..8c8acbaa9a 100644 --- a/src/reflect/value.go +++ b/src/reflect/value.go @@ -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()