Skip to content

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

Closed
@rsc

Description

@rsc

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} }
% 

Metadata

Metadata

Assignees

Labels

FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions