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

x/tools/go/analysis/passes/copylock: spurious errors after type check failure #67787

Closed
rsc opened this issue Jun 3, 2024 · 3 comments
Closed
Assignees
Labels
gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Jun 3, 2024

Seeing these errors from gopls in the workspace diagnostics list for these files.
The first error is real.
The second error is not real and should not be reported.

(The expression there is a type, not a value, so errors about copying values are confusing and wrong. Also the expected type at that point in the literal is a *T not a T, so once the first error is corrected, there will be no lock copy. Just as there is no error that T is not a *T, there should be no error that T holds a lock.)

/Users/rsc/src/rsc.io/tmp/goplsbug/x.go:8.31,8.32: T (type) is not an expression
/Users/rsc/src/rsc.io/tmp/goplsbug/x.go:8.31,8.32: literal copies lock value from T: rsc.io/tmp/goplsbug.T contains sync.Mutex

% cat go.mod
module rsc.io/tmp/goplsbug
% cat x.go
package main

import "sync"

type T struct{ mu sync.Mutex }
type T1 struct{ t *T }

func NewT1() *T1 { return &T1{T} }
% 
@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Jun 3, 2024
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Jun 3, 2024
@gopherbot gopherbot added this to the Unreleased milestone Jun 3, 2024
@rsc
Copy link
Contributor Author

rsc commented Jun 3, 2024

/cc @rfindley @adonovan

@rfindley
Copy link

rfindley commented Jun 3, 2024

/cc @findleyr

@adonovan adonovan changed the title x/tools/gopls: spurious lock value copy errors after type check failure x/tools/go/analysis/passes/copylock: spurious errors after type check failure Jun 3, 2024
@adonovan adonovan self-assigned this Jun 3, 2024
@adonovan adonovan modified the milestones: Unreleased, gopls/v0.16.0 Jun 3, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/589895 mentions this issue: go/analysis/passes/copylock: suppress error in ill-typed code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants