Skip to content

Commit

Permalink
lintcmd: file names are optional in error positions
Browse files Browse the repository at this point in the history
Closes: gh-1582
  • Loading branch information
dominikh committed Aug 6, 2024
1 parent 4a7ea0e commit 06d3e3e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lintcmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,10 @@ func filterAnalyzerNames(analyzers []string, checks []string) map[string]bool {
return allowedChecks
}

var posRe = regexp.MustCompile(`^(.+?):(\d+)(?::(\d+)?)?`)
// Note that the file name is optional and can be empty because of //line
// directives of the form "//line :1" (but not "//line :1:1"). See
// https://go.dev/issue/24183 and https://staticcheck.dev/issues/1582.
var posRe = regexp.MustCompile(`^(?:(.+?):)?(\d+)(?::(\d+)?)?`)

func parsePos(pos string) (token.Position, int, error) {
if pos == "-" || pos == "" {
Expand Down

0 comments on commit 06d3e3e

Please sign in to comment.