Skip to content

Syntax highlighting and Intellisense broken in VS Code 1.86+ when a string with "]" is cast to []byte #3158

@anirudhgiri

Description

@anirudhgiri

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 linux/amd64
  • 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.

    • 1.86.0
  • Check your installed extensions to get the version of the VS Code Go extension

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

    • Checking configured tools....
      GOBIN: undefined
      toolsGopath:
      gopath: /home/anirudh-g/go
      GOROOT: /snap/go/10489
      PATH: /snap/go/10489/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

    go: /snap/go/current/bin/go: go version go1.21.6 linux/amd64

    gopls: /home/anirudh-g/go/bin/gopls (version: v0.14.2 built with go: go1.21.4)
    gotests: not installed
    gomodifytags: not installed
    impl: not installed
    goplay: not installed
    dlv: /home/anirudh-g/go/bin/dlv (version: v1.21.0 built with go: go1.21.0)
    staticcheck: /home/anirudh-g/go/bin/staticcheck (version: v0.4.5 built with go: go1.21.0)

go env
Workspace Folder (playground): /home/anirudh-g/Documents/programming/golang/playground
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/anirudh-g/.cache/go-build'
GOENV='/home/anirudh-g/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/anirudh-g/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/anirudh-g/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/snap/go/10489'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/snap/go/10489/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/anirudh-g/Documents/programming/golang/playground/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2453955022=/tmp/go-build -gno-record-gcc-switches'

Share the Go related settings you have added/edited

"go.toolsManagement.autoUpdate": true,
  "go.alternateTools": {
    "go": "/snap/go/current/bin/go"
},

Describe the bug

If a string that contains the ] character is converted to a []byte, both syntax highlighting and intellisense stop working from that line onwards. All subsequent lines of code have incorrect syntax highlighting, and intellisense does not work on those lines of code. This only happens on VSCode version 1.86.0

Steps to reproduce the behavior:

  1. Take a project with multiple lines of correctly syntax highlighted code
  2. Add the line var myByteArray []byte = []byte("]") somewhere in the middle
  3. From that line onward, syntax highlighting and Intellisense ceases to work

Screenshots or recordings

Syntax highlighting on VSCode version 1.86.0:
image

Expected Syntax highlighting:
image (2)

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstream-vscodeIssues that are by problems in VS Code itself.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions