go: x/tools/gopls: occasional bogus syntax errors when editing large files in emacs via 'eglot'
What version are you using (go version)?
$ go version -m $(which gopls) /usr/local/google/home/bcmills/bin/gopls: devel +186f0220d0 Mon Oct 5 11:12:24 2020 -0400 path golang.org/x/tools/gopls mod golang.org/x/tools/gopls v0.5.1 h1:AF3Uh7HF08SZpKFfgJO6zfF3bbxyDXWqdkK4kMXiQ1o= dep github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= dep github.com/google/go-cmp v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k= dep github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= dep golang.org/x/mod v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4= dep golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= dep golang.org/x/tools v0.0.0-20200930165741-f1523d29dbb9 h1:1R38tQp22dcHpTKJPjgVa16FhlDy/kHEaCM/ndi/FIc= dep golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= dep honnef.co/go/tools v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k= dep mvdan.cc/gofumpt v0.0.0-20200802201014-ab5a8192947d h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ= dep mvdan.cc/xurls/v2 v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=
With GNU Emacs 27.1 and eglot 20200830.1254.
Does this issue reproduce with the latest release?
Yes.
What did you do?
Edited a large file ($GOROOT/src/cmd/go/internal/modget/get.go).
What did you expect to see?
Editor window consistently displaying up-to-date diagnostics.
What did you see instead?
Occasional bogus syntax errors for lines of the program, which persist until I run M-x eglot-reconnect or otherwise edit away the relevant portion of the file.
The bogus syntax errors seem to reflect gopls somehow having an inaccurate picture of the file state. (I’m not entirely sure whether the bug is due to erroneous didChange notifications in eglot or due to races or bugs in gopls. This bug reproduces frequently when editing large files but is difficult to provoke in a small standalone reproducer.)
[client-notification] Thu Oct 8 10:38:47 2020:
(:jsonrpc "2.0" :method "textDocument/didChange" :params
(:textDocument
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go" :version 2564)
:contentChanges
[(:range
(:start
(:line 1159 :character 40)
:end
(:line 1159 :character 40))
:rangeLength 0 :text "l")
(:range
(:start
(:line 1159 :character 41)
:end
(:line 1159 :character 41))
:rangeLength 0 :text "d")
(:range
(:start
(:line 1159 :character 42)
:end
(:line 1159 :character 42))
:rangeLength 0 :text " ")
(:range
(:start
(:line 1159 :character 43)
:end
(:line 1159 :character 43))
:rangeLength 0 :text "h")
(:range
(:start
(:line 1159 :character 44)
:end
(:line 1159 :character 44))
:rangeLength 0 :text "a")
(:range
(:start
(:line 1159 :character 45)
:end
(:line 1159 :character 45))
:rangeLength 0 :text "v")
(:range
(:start
(:line 1159 :character 46)
:end
(:line 1159 :character 46))
:rangeLength 0 :text "e")
(:range
(:start
(:line 1159 :character 47)
:end
(:line 1159 :character 47))
:rangeLength 0 :text " ")
(:range
(:start
(:line 1159 :character 48)
:end
(:line 1159 :character 48))
:rangeLength 0 :text "a")
(:range
(:start
(:line 1159 :character 49)
:end
(:line 1159 :character 49))
:rangeLength 0 :text "n")
(:range
(:start
(:line 1159 :character 50)
:end
(:line 1159 :character 50))
:rangeLength 0 :text " ")
(:range
(:start
(:line 1159 :character 51)
:end
(:line 1159 :character 51))
:rangeLength 0 :text "a")
(:range
(:start
(:line 1159 :character 52)
:end
(:line 1159 :character 52))
:rangeLength 0 :text "m")
(:range
(:start
(:line 1159 :character 53)
:end
(:line 1159 :character 53))
:rangeLength 0 :text "b")
(:range
(:start
(:line 1159 :character 54)
:end
(:line 1159 :character 54))
:rangeLength 0 :text "i")
(:range
(:start
(:line 1159 :character 55)
:end
(:line 1159 :character 55))
:rangeLength 0 :text "g")
(:range
(:start
(:line 1159 :character 56)
:end
(:line 1159 :character 56))
:rangeLength 0 :text "u")
(:range
(:start
(:line 1159 :character 57)
:end
(:line 1159 :character 57))
:rangeLength 0 :text "o")
(:range
(:start
(:line 1159 :character 58)
:end
(:line 1159 :character 58))
:rangeLength 0 :text "u")
(:range
(:start
(:line 1159 :character 59)
:end
(:line 1159 :character 59))
:rangeLength 0 :text "s")
(:range
(:start
(:line 1159 :character 60)
:end
(:line 1159 :character 60))
:rangeLength 0 :text " ")
(:range
(:start
(:line 1159 :character 61)
:end
(:line 1159 :character 61))
:rangeLength 0 :text "i")
(:range
(:start
(:line 1159 :character 62)
:end
(:line 1159 :character 62))
:rangeLength 0 :text "m")
(:range
(:start
(:line 1159 :character 63)
:end
(:line 1159 :character 63))
:rangeLength 0 :text "p")
(:range
(:start
(:line 1159 :character 64)
:end
(:line 1159 :character 64))
:rangeLength 0 :text "o")
(:range
(:start
(:line 1159 :character 65)
:end
(:line 1159 :character 65))
:rangeLength 0 :text "r")
(:range
(:start
(:line 1159 :character 66)
:end
(:line 1159 :character 66))
:rangeLength 0 :text "t")
(:range
(:start
(:line 1159 :character 67)
:end
(:line 1159 :character 67))
:rangeLength 0 :text ".")]))
[client-request] (id:830) Thu Oct 8 10:38:47 2020:
(:jsonrpc "2.0" :id 830 :method "textDocument/completion" :params
(:textDocument
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go")
:position
(:line 1159 :character 68)
:context
(:triggerKind 2 :triggerCharacter ".")))
[client-request] (id:831) Thu Oct 8 10:38:47 2020:
(:jsonrpc "2.0" :id 831 :method "textDocument/signatureHelp" :params
(:textDocument
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go")
:position
(:line 1159 :character 68)))
[client-request] (id:832) Thu Oct 8 10:38:47 2020:
(:jsonrpc "2.0" :id 832 :method "textDocument/hover" :params
(:textDocument
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go")
:position
(:line 1159 :character 68)))
[client-request] (id:833) Thu Oct 8 10:38:47 2020:
(:jsonrpc "2.0" :id 833 :method "textDocument/documentHighlight" :params
(:textDocument
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go")
:position
(:line 1159 :character 68)))
[server-reply] (id:830) Thu Oct 8 10:38:47 2020:
(:jsonrpc "2.0" :result
(:isIncomplete :json-false :items
[])
:id 830)
[internal] (id:820) Thu Oct 8 10:38:48 2020:
(:timed-out :textDocument/signatureHelp :id 820 :params
(:textDocument
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go")
:position
(:line 1158 :character 54)))
[internal] (id:821) Thu Oct 8 10:38:48 2020:
(:timed-out :textDocument/hover :id 821 :params
(:textDocument
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go")
:position
(:line 1158 :character 54)))
[internal] (id:822) Thu Oct 8 10:38:48 2020:
(:timed-out :textDocument/documentHighlight :id 822 :params
(:textDocument
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go")
:position
(:line 1158 :character 54)))
[client-notification] Thu Oct 8 10:38:48 2020:
(:jsonrpc "2.0" :method "textDocument/didChange" :params
(:textDocument
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go" :version 2580)
:contentChanges
[(:range
(:start
(:line 1157 :character 0)
:end
(:line 1157 :character 8))
:rangeLength 8 :text "")
(:range
(:start
(:line 1158 :character 0)
:end
(:line 1158 :character 8))
:rangeLength 8 :text "")
(:range
(:start
(:line 1159 :character 0)
:end
(:line 1159 :character 8))
:rangeLength 8 :text "")
(:range
(:start
(:line 1156 :character 71)
:end
(:line 1156 :character 193))
:rangeLength 122 :text " package example.com/foo/bar/baz, then we *must* resolve the package from example.com/foo: if we instead resolved it from ")
(:range
(:start
(:line 1156 :character 71)
:end
(:line 1156 :character 71))
:rangeLength 0 :text "\n")
(:range
(:start
(:line 1156 :character 71)
:end
(:line 1157 :character 0))
:rangeLength 1 :text "\n")
(:range
(:start
(:line 1157 :character 0)
:end
(:line 1157 :character 1))
:rangeLength 1 :text "")
(:range
(:start
(:line 1157 :character 0)
:end
(:line 1157 :character 0))
:rangeLength 0 :text " // ")
(:range
(:start
(:line 1157 :character 75)
:end
(:line 1157 :character 75))
:rangeLength 0 :text "\n")
(:range
(:start
(:line 1157 :character 75)
:end
(:line 1158 :character 0))
:rangeLength 1 :text "\n")
(:range
(:start
(:line 1158 :character 0)
:end
(:line 1158 :character 1))
:rangeLength 1 :text "")
(:range
(:start
(:line 1158 :character 0)
:end
(:line 1158 :character 0))
:rangeLength 0 :text " // ")
(:range
(:start
(:line 1158 :character 60)
:end
(:line 1158 :character 60))
:rangeLength 0 :text "\n")
(:range
(:start
(:line 1158 :character 60)
:end
(:line 1159 :character 0))
:rangeLength 1 :text "\n")
(:range
(:start
(:line 1159 :character 0)
:end
(:line 1159 :character 1))
:rangeLength 1 :text "")
(:range
(:start
(:line 1159 :character 0)
:end
(:line 1159 :character 0))
:rangeLength 0 :text " // ")]))
[server-reply] (id:831) Thu Oct 8 10:38:48 2020:
(:jsonrpc "2.0" :result nil :id 831)
[server-notification] Thu Oct 8 10:38:48 2020:
(:jsonrpc "2.0" :method "window/logMessage" :params
(:type 1 :message "2020/10/08 10:38:47 no signature help: cannot find an enclosing function\n position={1159 68}\n"))
[server-reply] (id:832) Thu Oct 8 10:38:48 2020:
(:jsonrpc "2.0" :result nil :id 832)
[server-reply] (id:833) Thu Oct 8 10:38:48 2020:
(:jsonrpc "2.0" :result
[]
:id 833)
[server-notification] Thu Oct 8 10:38:48 2020:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
(:uri "file:///usr/local/google/home/bcmills/go/src/cmd/go/internal/modget/get.go" :version 2580 :diagnostics
[(:range
(:start
(:line 1160 :character 0)
:end
(:line 1160 :character 0))
:severity 1 :source "syntax" :message "expected statement, found 'package'")]))
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (10 by maintainers)
You probably mean
M-q, orfill-paragraph. That sounds familiar. Please open a bug in the Eglot bug tracker. I’ll try to find the other bug there about a similar issue and connect both.That said, as I’ve explained to @bcmills, I’d need a more objective description of the observations. “random bogus errors” don’t help much. There are two bouts of editing action there. Can we have the file state before/after? Do the errors happen after any specific action?