Skip to content
New issue

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

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

Already on GitHub? # to your account

coverage: "illegal argument" vscode error from Go //line directive #2453

Closed
thanm opened this issue Sep 13, 2022 · 4 comments
Closed

coverage: "illegal argument" vscode error from Go //line directive #2453

thanm opened this issue Sep 13, 2022 · 4 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@thanm
Copy link

thanm commented Sep 13, 2022

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    go version devel go1.20-d4ff25ac69 Thu Aug 25 11:40:57 2022 +0000 linux/amd64

  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

Build info

golang.org/x/tools/gopls v0.9.4
golang.org/x/tools/gopls@(devel)
github.com/BurntSushi/toml@v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/google/go-cmp@v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
golang.org/x/exp/typeparams@v0.0.0-20220722155223-a9213eeb770e h1:7Xs2YCOpMlNqSQSmrrnhlzBXIE/bpMecZplbLePTJvE=
golang.org/x/mod@v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/sync@v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
golang.org/x/sys@v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
golang.org/x/text@v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/tools@v0.1.13-0.20220812184215-3f9b119300de h1:b68wxF4nfQjj1XTRHtjVjCximbhAwjztuzDEFGU+n9o=
golang.org/x/vuln@v0.0.0-20220725105440-4151a5aca1df h1:BkeW9/QJhcigekDUPS9N9bIb0v7gPKKmLYeczVAqr2s=
honnef.co/go/tools@v0.3.2 h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=
mvdan.cc/gofumpt@v0.3.1 h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8=
mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: devel go1.20-d4ff25ac69 Thu Aug 25 11:40:57 2022 +0000

  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.69.1 b06ae3b2d2dbfe28bca3134cc6be65935cdfea6a x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.35.2
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

Checking configured tools....
GOBIN: undefined
toolsGopath:
gopath: /ssd2/go1
GOROOT: /ssd2/go.master
PATH: /ssd2/go.master/bin:/ssd2/go1/bin:/ssd2/gobootstrap/bin:/usr/local/google/home/thanm/bin:/usr/lib/google-golang/bin:/usr/local/buildtools/java/jdk/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/ssd/gcc-trunk/cross/bin

go:	/ssd2/go.master/bin/go: go version devel go1.20-d4ff25ac69 Thu Aug 25 11:40:57 2022 +0000 linux/amd64

gotests:	not installed
gomodifytags:	not installed
impl:	not installed
goplay:	not installed
dlv:	/ssd2/go1/bin/dlv	(version: (devel) built with go: go1.18-7c94355b73)
staticcheck:	/ssd2/go1/bin/staticcheck	(version: (devel) built with go: undefined)
gopls:	/ssd2/go1/bin/gopls	(version: (devel) built with go: go1.20-d4ff25ac69)

go env
Workspace Folder (p): /ssd2/go1/src/github.com/thanm/nbt/cov-example/p
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/usr/local/google/home/thanm/.cache/go-build"
GOENV="/usr/local/google/home/thanm/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/ssd2/go1/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/ssd2/go1"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/ssd2/go.master"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/ssd2/go.master/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.20-d4ff25ac69 Thu Aug 25 11:40:57 2022 +0000"
GCCGO="/ssd/gcc-trunk/cross/bin/gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/ssd2/go1/src/github.com/thanm/nbt/cov-example/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build748014552=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

Haven't changed the go settings (as far as I know).

Describe the bug

This is a problem with editing a package whose source code has a "//line" directive, resulting in an unexpected error from vscode. Details below:

Steps to reproduce the behavior:

  1. download https://github.com/thanm/nbt.git
  2. git checkout 8471f630179370d381a9e2194c03f7538fe5a0f0
  3. cd to nbt/linedir
  4. code .
  5. bring up "blah.go" in the editor
  6. Select "Go: Toggle Test Coverage In Current Package"

This will result in this popup error:

VSCodeError

The problematic construct in the package is in this function:

func Baz() int {
	println(Foo(), Bar())
//line p.go:98989
	if G == 101 {
		return 3
	}
	println(Foo() + Bar())
	return 432
}

Note the line directive. If you remove this, things work properly.

@gopherbot gopherbot added this to the Untriaged milestone Sep 13, 2022
@hyangah hyangah changed the title vscode-go: "illegal argument" vscode error from Go //line directive coverage: "illegal argument" vscode error from Go //line directive Sep 13, 2022
@findleyr findleyr added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 16, 2022
@findleyr findleyr modified the milestones: Untriaged, vscode-go/later Sep 16, 2022
@findleyr
Copy link
Member

It looks like this error comes from VS Code itself, so we're producing incorrect position information somewhere.

@thanm
Copy link
Author

thanm commented Sep 16, 2022

The line number in question is large (98989); perhaps this overflows some VSCode limit?

@findleyr
Copy link
Member

@thanm thanks for pointing that out. This could also be a tool somewhere in the go test stack mishandling the line directive (compare golang/go#55043).

Needs investigation to see. Thanks for providing a reproducer.

@gopherbot
Copy link
Collaborator

Change https://go.dev/cl/447957 mentions this issue: src/goCover: ignore bogus-looking line/column data

@hyangah hyangah modified the milestones: vscode-go/later, v0.37.0 Nov 7, 2022
@golang golang locked and limited conversation to collaborators Nov 7, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants