-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/vet: false positive about recursive call to String method #23550
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
Comments
This might be because, until recently, vet did not always have type information. Should be fairly easy to make the check precise. |
As far as I understand, check for print functions will be executed by default before tests in go 1.10. Check results will be treated as errors. Can this be a reason to fix this before 1.10 or, at least, disable the check for this particular case? |
That's a good point. Not a regression in vet, but could qualify as a regression in test. /cc @rsc |
Actually, I'm not 100% sure if fmt is right here. I know that the program does run, but I don't follow the logic as to why it doesn't crash with an infinite recursion. /cc @robpike |
@mvdan the address is taken twice (once implicitly then once explicitly) so it's a |
Vet should not complain here. The code is legal and should (and does) print the address of |
Thank you both. I do understand the double pointer - what still confuses me at times is what rules apply when a method of |
Indeed - the problem is that vet tracked only the types that had a |
Change https://golang.org/cl/90417 mentions this issue: |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go1.9.3 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
Run
go vet
andgo run
on the following file:What did you expect to see?
go vet
reports no errors as program runs without problems, prints pointer address and exits normally.What did you see instead?
go vet
reportsarg &x in Sprint call causes recursive call to String method
.The text was updated successfully, but these errors were encountered: