-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: Value.Method does not do the same nil checks as the language #32021
Comments
In The program works as expected. |
Yes, this is a value method, but there is no value. When using |
@cuonglm there is an inconsistency between refection and direct code. @ianlancetaylor I think it in another way. The program prints
which indicates type
So I think the gc compiler does some unnecessary thing when evaluating |
It looks gccgo implements it correctly. The following program prints two same values if it is compiled with gc, but two different values if it is compiled with gccgo.
|
But gccgo also makes the program in the first comment panic. |
A short one which indicates
|
An example which proves the current reflection implementation is correct.
|
Thanks for that final example. I'm willing to believe that there is nothing to do here. |
@ianlancetaylor, so do you think type @griesemer, how do you think? |
I think it is no doubt that there is an inconsistency between refection and direct code, whether or not type T and its values haven't a M method.
|
I think, whether or not type
|
Reopening issue. |
Method
does not do the same nil checks as the language
Method
does not do the same nil checks as the language
Similarly for interface dynamic values:
|
What version of Go are you using (
go version
)?What did you do?
What did you expect to see?
Run okay.
What did you see instead?
panic.
Update: similarly for interface dynamic values
The text was updated successfully, but these errors were encountered: