Skip to content

x/tools/go/analysis/passes/modernize: reflectypefor leads to unused local varΒ #75767

@adonovan

Description

@adonovan

The reflecttypefor modernizer transforms code such as var zero T; return TypeOf(zero) to use TypeFor[T](), leaving the zero variable unused, which is an illegal program. The analyzer should check whether it eliminated the last use of the variable and if so eliminate the variable itself. This seems like a refactoring operator that would find use across our refactoring tools, perhaps some of which exhibit similar bugs.

Thanks to @cuishuang for pointing it out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.RefactoringIssues related to refactoring toolsToolsThis label describes issues relating to any tools in the x/tools repository.

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions