Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lintcmd: print TOML error on invalid config #1547

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module honnef.co/go/tools
go 1.22

require (
github.com/BurntSushi/toml v1.3.2
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678
golang.org/x/sys v0.20.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c h1:pxW6RcqyfI9/kWtOwnv/G+AzdKuy2ZrqINhenH4HyNs=
github.com/BurntSushi/toml v1.4.1-0.20240526193622-a339e1f7089c/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/exp/typeparams v0.0.0-20231108232855-2478ac86f678 h1:1P7xPZEwZMoBoz0Yze5Nx2/4pxj6nw9ZqHWXqP0iRgQ=
Expand Down
2 changes: 1 addition & 1 deletion go/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ func convertError(err error) []packages.Error {

case config.ParseError:
errs = append(errs, packages.Error{
Pos: fmt.Sprintf("%s:%d", err.Filename, err.Position.Line),
Pos: fmt.Sprintf("%s:%d:%d", err.Filename, err.Position.Line, err.Position.Col),
Msg: fmt.Sprintf("%s (last key parsed: %q)", err.Message, err.LastKey),
Kind: packages.ParseError,
})
Expand Down
7 changes: 6 additions & 1 deletion lintcmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ func failed(res runner.Result) []diagnostic {
msg = msg[1:]
}

cat := "compile"
if e.Kind == packages.ParseError {
cat = "config"
}

var posn token.Position
if e.Pos == "" {
// Under certain conditions (malformed package
Expand Down Expand Up @@ -456,7 +461,7 @@ func failed(res runner.Result) []diagnostic {
Diagnostic: runner.Diagnostic{
Position: posn,
Message: msg,
Category: "compile",
Category: cat,
},
Severity: severityError,
}
Expand Down
Loading