vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Go Syntax Check does not work with go.mod replace

Open haraldrudell opened this issue 1 year ago • 2 comments

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

    • golang.org/x/tools/gopls v0.14.2
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • Version: 1.85.2
  • Check your installed extensions to get the version of the VS Code Go extension

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

    • go: /opt/homebrew/Cellar/go/1.21.6/libexec/bin/go: go version go1.21.6 darwin/arm64

    gopls: /Users/foxyboy/go/bin/gopls (version: v0.14.2 built with go: go1.21.3) gotests: /Users/foxyboy/go/bin/gotests (version: v1.6.0 built with go: go1.21.0) gomodifytags: /Users/foxyboy/go/bin/gomodifytags (version: v1.16.0 built with go: go1.21.0) impl: /Users/foxyboy/go/bin/impl (version: v1.1.0 built with go: go1.21.0) goplay: /Users/foxyboy/go/bin/goplay (version: v1.0.0 built with go: go1.21.0) dlv: /Users/foxyboy/go/bin/dlv (version: v1.21.0 built with go: go1.21.0) staticcheck: /Users/foxyboy/go/bin/staticcheck (version: v0.4.5 built with go: go1.21.0)

Describe the bug

When editing multiple Go modules, with each edited module in a separate Code window, syntax errors occur in other Code windows when changing public identifiers in one Code window

Steps to reproduce the behavior:

  • Two Go Modules where module2 appears in workspace of module1 and modules import from each other’s packages
  • module1 has go.mod replace pointing to module2 in file system, getting an up-to-date version of module2 as opposed to the published package-versions of module2
  • one Code window for module1, another for module2
  1. Change the name of a public identifier used in both modules in one Code window
  2. GOOD: the identifier name is changed across all modules and Code windows
  3. BUG: syntax check now fails. In other Code windows than where the change was made, a red squiggly line appears under the new identifier name that was changed
  4. GETAROUND: exit and restart Visual Studio Code: syntax check now reports no errors

Can the syntax-check propagation somehow be made automatic, which is what is expected? Is there some easier GETAROUND than relaunching Visual Studio Code?

haraldrudell avatar Jan 23 '24 10:01 haraldrudell

Thanks for filing this issue @haraldrudell, yes that does sound like a bug. Does this occur both when renaming identifiers from module2 from the code window with module1 and from module2?

Also if you could provide a case to reproduce that would be great, I have not yet been able to reproduce. Thanks!

suzmue avatar Jan 24 '24 17:01 suzmue

Could you send a screenshot of the inaccurate diagnostics? In particular I am wondering what appears in the section after the error message (compiler(UndeclaredName) in the example screenshot): Screenshot 2024-01-25 at 4 31 17 PM

suzmue avatar Jan 25 '24 23:01 suzmue

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

gopherbot avatar Feb 24 '24 18:02 gopherbot