Open
Description
gopls version
v0.18.1
go env
-
What did you do?
Ran the modernize linter on this example:
package main
import "fmt"
type ssa []string
type ssb []string
var a ssa = ssa{"a", "b", "c"}
func main() {
var b ssb = append([]string{}, a...)
fmt.Println(b)
}
go run golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest -fix ./...
What did you see happen?
package main
import "slices"
import "fmt"
type ssa []string
type ssb []string
var a ssa = ssa{"a", "b", "c"}
func main() {
var b ssb = slices.Clone(a)
fmt.Println(b)
}
go build
./main.go:13:14: cannot use slices.Clone(a) (value of slice type ssa) as ssb value in variable declaration
What did you expect to see?
slices.Clone
not being suggested here, or at least not in a form that breaks compilation.
The example is silly, but I encountered this in real code when trying to run modernize against the OPA project, here specifically.
Editor and settings
No response
Logs
No response