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
x/tools/go/analysis/passes/copylock: does not detect tuple copies #45896
Comments
I have an idea for a fix for this problem
But I could use some help with directions on how to test the solution. I have stepped through it using dlv and it seems to do the right thing but some pointers for writing and running the unit tests would be helpful. |
@ajwans: You should be able to run the unit tests by running the |
It would be good to also test this change on functions returning multiple values. Function returns can be a bit tricky: https://github.com/golang/tools/blob/master/go/analysis/passes/copylock/copylock.go#L162-L165 Tests for these could go in: |
I looked into making this suggested change. It looks like this case is already considered and handled. The comments at copylocks.go:162 & copylocks.go:228 indicate that it not an error because a function is allowed to return a T{} with an empty lock. |
I created a PR for this golang/tools#319 |
golang/tools#319 has been merged and I think this issue can be closed. (the referenced issue in the Fixes line is |
Looks closed to me too. I believe the |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
An error indicating that it is a bad idea to copy a mutex.
What did you see instead?
Success
The text was updated successfully, but these errors were encountered: