Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reflect: inconsistent method indexing between Type.Method and Value.Method #22073

Closed
mdempsky opened this issue Sep 28, 2017 · 5 comments
Closed

Comments

@mdempsky
Copy link
Contributor

From @ianlancetaylor's example in #22053, this program prints "string int" but should print "string string": https://play.golang.org/p/Kw_V41dmX2

Possibly relatedly, this program segfaults when int is replaced by a local named type: https://play.golang.org/p/k45kuWP75S

/cc @crawshaw

@mdempsky
Copy link
Contributor Author

mdempsky commented Sep 28, 2017

Hm, this issue doesn't reproduce at master.

Edit: Disregard. I somehow mangled the test file when copying locally.

@mdempsky
Copy link
Contributor Author

mdempsky commented Sep 28, 2017

It looks like the issue is Type.Method uses (*rtype).exportedMethods, which filters out unexported methods. However, Value.Method just directly indexes into t.uncommonType().methods().

It seems unfortunate that package reflect needs to filter methods like this anyway. I would think the compiler could just statically partition exported and unexported ones.

@crawshaw
Copy link
Member

I believe we need the unexported method data for itabs in the runtime. But you're right that it could be statically partitioned.

@gopherbot
Copy link
Contributor

Change https://golang.org/cl/66770 mentions this issue: reflect: fix method indexing for non-ASCII exported methods

@mdempsky
Copy link
Contributor Author

@crawshaw Yeah, runtime itab construction and reflect.Implements both need non-exported methods.

@golang golang locked and limited conversation to collaborators Sep 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants