Skip to content

Error using snippets with "var" as default name #969

@RomanKornev

Description

@RomanKornev

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

  • Run go version to get version of Go
    • go version go1.15.5 linux/amd64
  • Run gopls -v version to get version of Gopls if you are using the language server.
    • golang.org/x/tools/gopls v0.5.3
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • 1.51.1 x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.19.0
  • Run go env to get the go development environment details
    • GO111MODULE=""
      GOARCH="amd64"
      GOBIN=""
      GOCACHE="/home/df/.cache/go-build"
      GOENV="/home/df/.config/go/env"
      GOEXE=""
      GOFLAGS=""
      GOHOSTARCH="amd64"
      GOHOSTOS="linux"
      GOINSECURE=""
      GOMODCACHE="/home/df/go/pkg/mod"
      GONOPROXY=""
      GONOSUMDB=""
      GOOS="linux"
      GOPATH="/home/df/go"
      GOPRIVATE=""
      GOPROXY="https://proxy.golang.org,direct"
      GOROOT="/usr/local/go"
      GOSUMDB="sum.golang.org"
      GOTMPDIR=""
      GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
      GCCGO="gccgo"
      AR="ar"
      CC="gcc"
      CXX="g++"
      CGO_ENABLED="1"
      GOMOD="/c/Python/Go/Crypto/go.mod"
      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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build490426795=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

    // #region GO
    "go.useLanguageServer": true,
    "go.languageServerFlags": [
        "-rpc.trace"
    ],
    "go.languageServerExperimentalFeatures": {
        "diagnostics": true,
        "documentLink": true,
        "format": true
    },
    "[go]": {
        "editor.insertSpaces": false,
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        },
        // "editor.snippetSuggestions": "none"
    },
    "[go.mod]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        },
    },
    "gopls": {
        "completeUnimported": true,
        "deepCompletion": true,
        "usePlaceholders": true,
        "staticcheck":true
    },
    // #endregion GO

Describe the bug

Some snippets with "var" as the default name produce Error: "expected 1 expression"

Steps to reproduce the behavior:

  1. Type forr and iterate over a slice using a default "var" name
  2. Error: "expected 1 expression"
  3. Change name of "var" to any other name - error is gone

Screenshots or recordings

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions