-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/gopls: error range for function with missing return is the entire function body #35139
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
Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here. |
Thanks for the report. Caused by CL 202542. I will probably revert some of the changes in that CL soon. |
Change https://golang.org/cl/203287 mentions this issue: |
CL 203287 will address this by highlighting only the function name. There is definitely a lot more work to be done here though. If we were able to match on the error type, we could specifically show an error on the ending curly brace, or something like that. |
Thanks for taking a look. I checked out the CL and applied it to see, but it appears as though the function bodies are still getting squiggled when the function is missing a return case. |
Thank you for checking that! I forgot that I had added a special case for that file to skip checking ranges on diagnostics 🤦♀It should work now. |
It works, now, thanks. 😄 |
Please answer these questions before submitting your issue. Thanks!
What did you do?
Wrote a somewhat large function by coping incomplete code from somewhere else. It's missing the return at the end. Like:
What did you expect to see?
A reasonable squiggle that shows me where the issue is.
What did you see instead?
The error range for this parser error is the entire function body:
I spent way too much time trying to figure out what was actually wrong with this function after pasting the code (I thought there may have been a file content desync), only to see that it's just missing a return.
This is probably related to the fix for #29150 that was recently merged. Previously, I believe the diagnostic range for this was just the location of the opening curly brace, but now it's the range of the function.
I'm not sure what a better place would be to hint that something is wrong (The end of the function where a return is missing? The return type declaration? The function name?), but the current behavior seems not so good to me.
Build info
Go info
The text was updated successfully, but these errors were encountered: