Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Types are not being automatically updated/checked #2848

Closed
OmisNomis opened this issue Oct 21, 2019 · 6 comments
Closed

Types are not being automatically updated/checked #2848

OmisNomis opened this issue Oct 21, 2019 · 6 comments
Labels
upstream-gopls Issue for gopls

Comments

@OmisNomis
Copy link

Describe the bug
If I'm working on a Go project and I change a type the IntelliSense type checking isn't updated.

This seems to only happen in large projects, so it's hard to provide reproducible steps, but if a type is changed somewhere else in the project that should cause an error, it doesn't.

Equally, if there is a type error and I fix it, the error persists because it doesn't acknowledge it has been updated.

Eventually, I have to close VSCode down completely and re-open it to get it to recognise the difference - which is annoying.

VSCode settings
Preferences: Open Settings (JSON)

{
    "explorer.autoReveal": false,
    "editor.renderIndentGuides": true,
    "editor.tabSize": 2,
    "editor.wordWrapColumn": 80,
    "editor.detectIndentation": true,
    "extensions.ignoreRecommendations": false,
    "window.zoomLevel": 1,
    "editor.fontLigatures": true,
    "editor.fontFamily": "Cascadia Code",
    "editor.fontWeight": "normal",
    "editor.fontSize": 12,
    "workbench.editor.showTabs": true,
    "terminal.external.osxExec": "iTerm.app",
    "terminal.integrated.shell.osx": "zsh",
    "telemetry.enableCrashReporter": false,
    "telemetry.enableTelemetry": false,
    "git.autofetch": true,
    "explorer.confirmDragAndDrop": false,
    "workbench.editor.enablePreview": true,
    "gitlens.advanced.messages": {
        "suppressShowKeyBindingsNotice": true
    },
    "sync.host": "",
    "sync.pathPrefix": "",
    "sync.quietSync": false,
    "sync.askGistName": false,
    "sync.removeExtensions": true,
    "sync.syncExtensions": true,
    "sync.autoDownload": false,
    "sync.autoUpload": false,
    "sync.lastDownload": "",
    "sync.forceDownload": false,
    "breadcrumbs.enabled": true,
    "breadcrumbs.filePath": "off",
    "files.autoSave": "onFocusChange",
    "go.testFlags": [
        "-v"
    ],
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "workbench.iconTheme": "material-icon-theme",
    "editor.acceptSuggestionOnCommitCharacter": false,
    "emmet.includeLanguages": {
        "html": "html",
        "erb": "erb",
        "javascript": "javascriptreact",
        "vue": "html",
        "ejs": "html"
    },
    "files.exclude": {
        "**/.classpath": true,
        "**/.project": true,
        "**/.settings": true,
        "**/.factorypath": true
    },
    "markdown.preview.doubleClickToSwitchToEditor": false,
    "editor.formatOnSave": true,
    "go.formatTool": "goimports",
    "go.useLanguageServer": true,
    "workbench.colorTheme": "Palenight Theme",
    "yaml.format.enable": false,
    "cSpell.diagnosticLevel": "Hint"
}

To Reproduce

This seems to only happen in large projects, so it's hard to provide reproducible steps

Expected behavior
I expect the new type to be registered, so the error goes away or is shown.

Screenshots
If applicable, add screenshots to help explain your problem.

System information:

  • OS: OSX
  • Extension Version: 10.14.6
  • VS Code Version: 1.39.2

Additional context
Add any other context about the problem here.

@OmisNomis
Copy link
Author

UPDATE

I disabled every plugin I have, other than the Go plugin, and the issue persists.

@OmisNomis
Copy link
Author

OmisNomis commented Oct 25, 2019

I've been able to replicate the issue in such a way I can share the steps (code is shared first and steps at the bottom of this comment).

Project structure:

.
+-- config
|   +-- config.go
+-- config.txt
+-- go.mod
+-- main.go

And the actual files themselves:

// main.go
package main

import "play/config"

func main() {
	config.Hello("Bob")
}
// go.mod
module play

go 1.12
# config.txt
package config

import "log"

func Hello(u int) {
	log.Println("Hello", u)
}
// config/config.go
package config

import "log"

func Hello(u string) {
	log.Println("Hello", u)
}

Steps to reproduce:

  1. Open main.go and observe the parameter type of Hello

  2. Run main.go

2019/10/25 10:23:15 Hello Bob
  1. Run echo "$(<config.txt )" > config/config.go to overwrite the contents of config.go

  2. Observe the parameter type of Hello has not changed using IntelliSense

  3. Run main.go again and see the type has changed

./main.go:6:15: cannot use "Bob" (type string) as type int in argument to config.Hello

Is this the expected behaviour? Is there a way to tell VSCode to update? In this small project, just opening the config.go file updates the type, but in large projects a full editor restart is required.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Nov 4, 2019

Apologies for not getting to this sooner @OmisNomis

@stamblerre The language server is powering the auto completion & diagnostics, modules are in use. Can you please take a look here?

@stamblerre
Copy link
Contributor

We have not yet finished implementing support for watching files changed outside of the editor in gopls (see golang/go#31553), which is why you are seeing this behavior.

@stamblerre
Copy link
Contributor

@ramya-rao-a: golang/go#31553 is now closed and will be part of gopls/v0.3.0, so I think that this issue can be closed.

@ramya-rao-a
Copy link
Contributor

Thanks @stamblerre

For folks who want to try the fix before the next version is out, please try out gopls from the master branch. You can download it by running

GO111MODULE=on 
go get golang.org/x/tools/gopls@master golang.org/x/tools@master

@vscodebot vscodebot bot locked and limited conversation to collaborators Mar 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upstream-gopls Issue for gopls
Projects
None yet
Development

No branches or pull requests

3 participants