Skip to content

x/tools/gopls/internal/analyzer/modernize: bug in slices.Contains transformation #71313

Closed
@adonovan

Description

@adonovan

[split out of https://github.com//issues/70815#issuecomment-2598663385]

@findleyr says:
I encountered a bug in the slices.Contains modernizer today.

Modernizing using slices.Contains here results in an error:
https://cs.opensource.google/go/x/tools/+/master:gopls/internal/golang/highlight.go;l=348;drc=344e48255740736de8c8277e9a286cf3231c7e13

		case *ast.CallExpr:
			// If cursor is an arg in a callExpr, we don't want control flow highlighting.
			if i > 0 {
				for _, arg := range n.Args {
					if arg == path[i-1] {
						return
					}
				}
			}

Error is: S (type []ast.Expr) does not satisfy ~[]E.
For now, I think we need to check that the types in the match condition are identical.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugReportIssues describing a possible bug in the Go implementation.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