x/tools/gopls: unusedparams analyzer reports false positive due to build tags #65479
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
gopls/analysis
Issues related to running analysis in gopls
gopls
Issues related to the Go language server, gopls.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
The analysis believes that this function is assigned to a variable that is only ever used in call position--because it is never used at all. In fact it is used in non-call position, for an assignment to the variable, though only in a file tagged for GOOS=windows, which of course the analysis cannot see. Consequently it falsely reports that the parameter can be safely removed.
One possibility would be to observe that pass.IgnoredGoFiles contains one or more files, in particular files with build tags, and to conservatively assume that these extra files contain assignments to all variables such as isWindowsErrLockViolation.
This is really a representative for a whole class of built-tag-related analyzer problems.
The text was updated successfully, but these errors were encountered: