You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
cmd/compile: reflect.Value.MethodByName used as a method expression value is not seen as a reflection lookup; linker prunes the method #82047
go tool nm has no main.T.M; -ldflags=-dumpdep shows no <ReflectMethod> edge. Same with the method expression in a package variable, a composite literal, or a static table, and with reflect.Value.Method.
What did you expect to see?
M called. usemethod in cmd/compile/internal/walk/expr.go marks callers of MethodByName and records constant names, but only for calls. A method expression used as a value lowers to a plain function reference, so the linker never learns about the lookup. Wrapping the call in a func literal makes it work. Bound method values and reflect.Type.MethodByName are fine; the compiler emits wrappers with real calls for those.
Found while working on #72895. Fix with cmd/link dead-code fixtures ready; CL to follow.
Hi @dims, sounds like you are well on your way to a fix, but in case useful, a bisect seemed to land on 6b52bfa:
first BAD: 6b52bfa393 | 2023-09-01 | cmd/link: remove special cases for Method() and MethodByName().
GOOD parent: e802f211b0 | 2023-09-01 | cmd/compile: special-case MethodByName(string literal) to keep the DCE enabled.
Activity
cmd/compile: mark function values of reflect.Value.Method and MethodB…
cmd/compile: mark function values of reflect.Value.Method and MethodB…
thepudds commentedon Oct 7, 2026
Hi @dims, sounds like you are well on your way to a fix, but in case useful, a bisect seemed to land on 6b52bfa:
CC @dominiquelefevre @cherrymui
cmd/compile: mark function values of reflect.Value.Method and MethodB…
gopherbot commentedon Oct 7, 2026
Change https://go.dev/cl/846145 mentions this issue:
cmd/compile: mark function values of reflect.Value.Method and MethodByNamecmd/compile: mark function values of reflect.Value.Method and MethodB…
dims commentedon Oct 7, 2026
@thepudds thanks for the bisect! I think i have a tiny fix, let's see if that's good enough. please do peek when you get a chance.
gabyhelp commentedon Oct 7, 2026
Related Issues
Related Code Changes
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
cmd/compile: mark function values of reflect.Value.Method and MethodB…
cmd/compile: mark function values of reflect.Value.Method and MethodB…