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

Invalid value when you point the mouse at a variable #2651

Closed
scootpl opened this issue Feb 7, 2023 · 5 comments
Closed

Invalid value when you point the mouse at a variable #2651

scootpl opened this issue Feb 7, 2023 · 5 comments

Comments

@scootpl
Copy link

scootpl commented Feb 7, 2023

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 go1.19.4 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • Version: 1.75.0 (Universal)
      Commit: e2816fe719a4026ffa1ee0189dc89bdfdbafb164
      Date: 2023-02-01T15:24:42.903Z
      Electron: 19.1.9
      Chromium: 102.0.5005.194
      Node.js: 16.14.2
      V8: 10.2.154.23-electron.0
      OS: Darwin x64 22.2.0
      Sandboxed: No
  • Check your installed extensions to get the version of the VS Code Go extension

    • v0.37.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

    • go: /usr/local/bin/go: go version go1.19.4 darwin/amd64

    gotests: /Users/scoot/go/bin/gotests (version: v1.6.0 built with go: go1.19.1)
    gomodifytags: /Users/scoot/go/bin/gomodifytags (version: v1.16.0 built with go: go1.19.1)
    impl: /Users/scoot/go/bin/impl (version: v1.1.0 built with go: go1.19.1)
    goplay: /Users/scoot/go/bin/goplay (version: v1.0.0 built with go: go1.19.1)
    dlv: /Users/scoot/go/bin/dlv (version: v1.9.1 built with go: go1.19.1)
    staticcheck: /Users/scoot/go/bin/staticcheck (version: v0.3.3 built with go: go1.19.1)
    gopls: /Users/scoot/go/bin/gopls (version: v0.11.0 built with go: go1.19.3)

go env
Workspace Folder (rtd): /Users/scoot/go/src/github.com/scootpl/rtd
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/scoot/Library/Caches/go-build"
GOENV="/Users/scoot/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/scoot/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/scoot/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.19.4/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.19.4/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.4"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/scoot/go/src/github.com/scootpl/rtd/go.mod"
GOWORK=""
CGO_CFLAGS="-mmacosx-version-min=11.2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/vz/n0zz1ht53bg3xz7njjzpjyhr0000gp/T/go-build1704131766=/tmp/go-build -gno-record-gcc-switches -fno-common"

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

"go.gopath": "~/go",

Describe the bug

Invalid value when you point the mouse at a variable.

Steps to reproduce the behavior:

  1. Define a variable or constant and comment it out
  2. Redefine the same variable with different value line below
  3. Use variable in your app
  4. When you point the mouse at a variable, you will see an invalid value

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.
216848178-4ce5c690-3df5-4fe0-b881-06378fe20e7b

@gopherbot gopherbot added this to the Untriaged milestone Feb 7, 2023
@suzmue
Copy link
Contributor

suzmue commented Feb 7, 2023

The commented out value is treated as a doc comment (https://tip.golang.org/doc/comment) since it appears directly before a var, which is then included in the hover as additional information. If you don't want it to be included as a doc comment, you can add an empty new line between the comment and a int = 10.

var (
  // a = 50
  //

  a int = 10
)

@scootpl
Copy link
Author

scootpl commented Feb 7, 2023

I thought that in this particular case the commented variable should not be considered as a doc comment. But it is not a big problem. Thank you.

@findleyr
Copy link
Contributor

findleyr commented Feb 8, 2023

I noticed this as well, and agree!

This is filed as https://go.dev/issue/58220. I just revamped our hover logic, and will fix this for the next release.

@findleyr
Copy link
Contributor

findleyr commented Mar 2, 2023

Closing this in favor of golang/go#58220

@findleyr findleyr closed this as not planned Won't fix, can't repro, duplicate, stale Mar 2, 2023
@findleyr
Copy link
Contributor

findleyr commented Mar 2, 2023

Closing this in favor of golang/go#58220

@golang golang locked and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants