reflect: cannot call *T methods on addressable Values of type T #24184
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
I would expect this program to work:
Currently, it produces
panic: reflect: call of reflect.Value.Call on zero Value
panic, becauseM
is not in the method set ofT
(only*T
).This seems overly strict to me. The Go spec allows calling
t.M()
where t is an addressable value of type T; it's just implicitly executed as(&t).M()
. I would expect package reflect to handle this implicit dereference, but it does not.For comparison, the spec also allows an implicit dereference to call value-receiver methods on pointer types, and package reflect does perform this implicit dereference.
/cc @ianlancetaylor @dsnet
The text was updated successfully, but these errors were encountered: