Skip to content

x/tools/gopls: crash in template.weakMatch #50430

@doug4j

Description

@doug4j

gopls version: v0.7.4
gopls flags:
update flags: proxy
extension version: 0.30.0
go version: 1.17.5
environment: Visual Studio Code darwin
initialization error: undefined
issue timestamp: Thu, 23 Dec 2021 22:39:37 GMT
restart history:
Thu, 23 Dec 2021 14:29:56 GMT: activation (enabled: true)

ATTENTION: PLEASE PROVIDE THE DETAILS REQUESTED BELOW.

Describe what you observed.

In editing a loop within a go template (a file whose extension is ".tmpl"), received the following crash. I was editing items with a {{range ...}} clause.

panic: runtime error: index out of range [1] with length 1

goroutine 17190 [running]:
golang.org/x/tools/internal/lsp/template.weakMatch({0x1400f37ec90, 0x1}, {0x1400e980090, 0x2})
	  completion.go:278  0x164
golang.org/x/tools/internal/lsp/template.(*completer).complete(0x140161fef00)
	  completion.go:137  0x27c
golang.org/x/tools/internal/lsp/template.Completion({0x10528be58, 0x1401dbf8480}, {0x1052b1040, 0x1400e2c0200}, {0x10529f770, 0x140115b5ec0}, {0x15a, 0x106}, {0x3ff0000000000000, {0x0, ...}})
	  completion.go:58  0x2c4
golang.org/x/tools/internal/lsp.(*Server).completion(0x14000112480, {0x10528be58, 0x1401dbf8480}, 0x1401d7c8a00)
	  completion.go:37  0x188
golang.org/x/tools/internal/lsp.(*Server).Completion(0x14000112480, {0x10528be58, 0x1401dbf8480}, 0x1401d7c8a00)
	  server_gen.go:32  0x40
golang.org/x/tools/internal/lsp/protocol.serverDispatch({0x10528be58, 0x1401dbf8480}, {0x1052b4e70, 0x14000112480}, 0x1401acf0060, {0x10528c0c0, 0x1401dbf8400})
	  tsserver.go:398  0x1e88
golang.org/x/tools/internal/lsp/protocol.ServerHandler.func1({0x10528be58, 0x1401dbf8480}, 0x1401acf0060, {0x10528c0c0, 0x1401dbf8400})
	  protocol.go:154  0x84
golang.org/x/tools/internal/lsp/lsprpc.handshaker.func1({0x10528be58, 0x1401dbf8480}, 0x1401acf0060, {0x10528c0c0, 0x1401dbf8400})
	  lsprpc.go:506  0x8a4
golang.org/x/tools/internal/jsonrpc2.MustReplyHandler.func1({0x10528be58, 0x1401dbf8480}, 0x1400aeeb1d0, {0x10528c0c0, 0x1401dbf8400})
	  handler.go:35  0xf4
golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1.2(0x14015274c00, 0x1401ace6420, 0x1400014ceb0, {0x10528be58, 0x1401dbf8480}, 0x1400aeeb1d0, {0x10528c0c0, 0x1401dbf8400})
	  handler.go:103  0x6c
created by golang.org/x/tools/internal/jsonrpc2.AsyncHandler.func1
	  handler.go:100  0x15c
[Error - 5:39:19 PM] 

NOTE: THESE MAY CONTAIN SENSITIVE INFORMATION ABOUT YOUR CODEBASE.
DO NOT SHARE LOGS IF YOU ARE WORKING IN A PRIVATE REPOSITORY.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions