joaotavora / eglot

A client for Language Server Protocol servers
GNU General Public License v3.0
2.27k stars 200 forks source link

Flymake backend signals errors ("obsolete report") when editing code in an indirect/cloned buffer #843

Open phst opened 2 years ago

phst commented 2 years ago

LSP transcript - M-x eglot-events-buffer (mandatory unless Emacs inoperable)

[internal] Wed Feb 23 14:15:25 2022:
(:message "Running language server: /usr/bin/clangd")
[client-request] (id:1) Wed Feb 23 14:15:25 2022:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
      (:processId 2084824 :rootPath "/tmp/" :rootUri "file:///tmp" :initializationOptions #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                                        ())
              :capabilities
              (:workspace
               (:applyEdit t :executeCommand
                   (:dynamicRegistration :json-false)
                   :workspaceEdit
                   (:documentChanges :json-false)
                   :didChangeWatchedFiles
                   (:dynamicRegistration t)
                   :symbol
                   (:dynamicRegistration :json-false)
                   :configuration t)
               :textDocument
               (:synchronization
            (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
            :completion
            (:dynamicRegistration :json-false :completionItem
                          (:snippetSupport :json-false :deprecatedSupport t :tagSupport
                                   (:valueSet
                                [1]))
                          :contextSupport t)
            :hover
            (:dynamicRegistration :json-false :contentFormat
                          ["plaintext"])
            :signatureHelp
            (:dynamicRegistration :json-false :signatureInformation
                          (:parameterInformation
                           (:labelOffsetSupport t)
                           :activeParameterSupport t))
            :references
            (:dynamicRegistration :json-false)
            :definition
            (:dynamicRegistration :json-false :linkSupport t)
            :declaration
            (:dynamicRegistration :json-false :linkSupport t)
            :implementation
            (:dynamicRegistration :json-false :linkSupport t)
            :typeDefinition
            (:dynamicRegistration :json-false :linkSupport t)
            :documentSymbol
            (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind
                          (:valueSet
                           [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]))
            :documentHighlight
            (:dynamicRegistration :json-false)
            :codeAction
            (:dynamicRegistration :json-false :codeActionLiteralSupport
                          (:codeActionKind
                           (:valueSet
                        ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"]))
                          :isPreferredSupport t)
            :formatting
            (:dynamicRegistration :json-false)
            :rangeFormatting
            (:dynamicRegistration :json-false)
            :rename
            (:dynamicRegistration :json-false)
            :publishDiagnostics
            (:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport
                         (:valueSet
                          [1 2])))
               :experimental #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                           ()))))
[stderr] I[14:15:25.229] clangd version redacted
[stderr] I[14:15:25.229] Features: linux+grpc
[stderr] I[14:15:25.229] PID: 2084852
[stderr] I[14:15:25.229] Working directory: /tmp
[stderr] I[14:15:25.229] argv[0]: /usr/bin/clangd
[server-reply] (id:1) Wed Feb 23 14:15:25 2022:
(:id 1 :jsonrpc "2.0" :result
     (:capabilities
      (:astProvider t :callHierarchyProvider t :clangdInlayHintsProvider t :codeActionProvider
            (:codeActionKinds
             ["quickfix" "refactor" "info"])
            :compilationDatabase
            (:automaticReload t)
            :completionProvider
            (:allCommitCharacters
             [" " " " "(" ")" "[" "]" "{" "}" "<" ">" ":" ";" "," "+" "-" "/" "*" "%" "^" "&" "#" "?" "." "=" "\"" "'" "|"]
             :resolveProvider :json-false :triggerCharacters
             ["." "<" ">" ":" "\"" "/" "*"])
            :declarationProvider t :definitionProvider t :documentFormattingProvider t :documentHighlightProvider t :documentLinkProvider
            (:resolveProvider :json-false)
            :documentOnTypeFormattingProvider
            (:firstTriggerCharacter "\n" :moreTriggerCharacter
                        [])
            :documentRangeFormattingProvider t :documentSymbolProvider t :executeCommandProvider
            (:commands
             ["clangd.applyFix" "clangd.applyTweak"])
            :hoverProvider t :implementationProvider t :memoryUsageProvider t :referencesProvider t :renameProvider t :selectionRangeProvider t :semanticTokensProvider
            (:full
             (:delta t)
             :legend
             (:tokenModifiers
              ["declaration" "deprecated" "deduced" "readonly" "static" "abstract" "virtual" "dependentName" "defaultLibrary" "usedAsMutableReference" "functionScope" "classScope" "fileScope" "globalScope"]
              :tokenTypes
              ["variable" "variable" "parameter" "function" "method" "function" "property" "variable" "class" "interface" "enum" "enumMember" "type" "type" "unknown" "namespace" "typeParameter" "concept" "type" "macro" "comment"])
             :range :json-false)
            :signatureHelpProvider
            (:triggerCharacters
             ["(" ")" "{" "}" "<" ">" ","])
            :textDocumentSync
            (:change 2 :openClose t :save t)
            :typeDefinitionProvider t :typeHierarchyProvider t :workspaceSymbolProvider t)
      :serverInfo
      (:name "clangd" :version "clangd version redacted linux+grpc x86_64-grtev4-linux-gnu")))
[client-notification] Wed Feb 23 14:15:25 2022:
(:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                ()))
[client-notification] Wed Feb 23 14:15:25 2022:
(:jsonrpc "2.0" :method "textDocument/didOpen" :params
      (:textDocument
       (:uri "file:///tmp/a.c" :version 0 :languageId "c" :text "int main(void) {\n  return 0; \n}\n")))
[client-notification] Wed Feb 23 14:15:25 2022:
(:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params
      (:settings nil))
[server-notification] Wed Feb 23 14:15:25 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
      (:diagnostics
       []
       :uri "file:///tmp/a.c" :version 0))
[stderr] I[14:15:25.232] Starting LSP over stdin/stdout
[stderr] I[14:15:25.232] <-- initialize(1)
[stderr] I[14:15:25.232] --> reply:initialize(1) 0 ms
[stderr] I[14:15:25.241] <-- initialized
[stderr] I[14:15:25.245] <-- textDocument/didOpen
[stderr] I[14:15:25.246] Failed to find compilation database for /tmp/a.c
[stderr] I[14:15:25.246] ASTWorker building file /tmp/a.c version 0 with command clangd fallback
[stderr] [/tmp]
[stderr] /usr/lib/llvm-13/bin/clang -resource-dir=redacted -- /tmp/a.c
[stderr] I[14:15:25.247] <-- workspace/didChangeConfiguration
[stderr] I[14:15:25.260] --> textDocument/publishDiagnostics
[client-request] (id:2) Wed Feb 23 14:15:26 2022:
(:jsonrpc "2.0" :id 2 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 0 :character 0)))
[client-request] (id:3) Wed Feb 23 14:15:26 2022:
(:jsonrpc "2.0" :id 3 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 0 :character 0)))
[client-request] (id:4) Wed Feb 23 14:15:26 2022:
(:jsonrpc "2.0" :id 4 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 0 :character 0)))
[server-reply] (id:3) Wed Feb 23 14:15:26 2022:
(:id 3 :jsonrpc "2.0" :result nil)
[server-reply] (id:2) Wed Feb 23 14:15:26 2022:
(:id 2 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
               []))
[server-reply] (id:4) Wed Feb 23 14:15:26 2022:
(:id 4 :jsonrpc "2.0" :result
     [])
[stderr] I[14:15:26.177] <-- textDocument/signatureHelp(2)
[stderr] I[14:15:26.185] <-- textDocument/hover(3)
[stderr] I[14:15:26.185] --> reply:textDocument/hover(3) 0 ms
[stderr] I[14:15:26.188] --> reply:textDocument/signatureHelp(2) 10 ms
[stderr] I[14:15:26.192] <-- textDocument/documentHighlight(4)
[stderr] I[14:15:26.192] --> reply:textDocument/documentHighlight(4) 0 ms
[client-request] (id:5) Wed Feb 23 14:15:28 2022:
(:jsonrpc "2.0" :id 5 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 12)))
[client-request] (id:6) Wed Feb 23 14:15:28 2022:
(:jsonrpc "2.0" :id 6 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 12)))
[client-request] (id:7) Wed Feb 23 14:15:28 2022:
(:jsonrpc "2.0" :id 7 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 12)))
[server-reply] (id:6) Wed Feb 23 14:15:28 2022:
(:id 6 :jsonrpc "2.0" :result nil)
[server-reply] (id:5) Wed Feb 23 14:15:28 2022:
(:id 5 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
               []))
[server-reply] (id:7) Wed Feb 23 14:15:28 2022:
(:id 7 :jsonrpc "2.0" :result
     [])
[stderr] I[14:15:28.118] <-- textDocument/signatureHelp(5)
[stderr] I[14:15:28.130] <-- textDocument/hover(6)
[stderr] I[14:15:28.131] --> reply:textDocument/hover(6) 0 ms
[stderr] I[14:15:28.131] --> reply:textDocument/signatureHelp(5) 12 ms
[stderr] I[14:15:28.139] <-- textDocument/documentHighlight(7)
[stderr] I[14:15:28.139] --> reply:textDocument/documentHighlight(7) 0 ms
[internal] (id:8) Wed Feb 23 14:15:28 2022:
(:deferring :textDocument/signatureHelp :id 8 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 11)))
[internal] (id:9) Wed Feb 23 14:15:28 2022:
(:deferring :textDocument/hover :id 9 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 11)))
[internal] (id:10) Wed Feb 23 14:15:28 2022:
(:deferring :textDocument/documentHighlight :id 10 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 11)))
[client-notification] Wed Feb 23 14:15:28 2022:
(:jsonrpc "2.0" :method "textDocument/didChange" :params
      (:textDocument
       (:uri "file:///tmp/a.c" :version 1)
       :contentChanges
       [(:range
         (:start
          (:line 1 :character 11)
          :end
          (:line 1 :character 12))
         :rangeLength 1 :text "")]))
[internal] Wed Feb 23 14:15:28 2022:
(:maybe-run-deferred
 (8 9 10))
[client-request] (id:8) Wed Feb 23 14:15:28 2022:
(:jsonrpc "2.0" :id 8 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 11)))
[client-request] (id:9) Wed Feb 23 14:15:28 2022:
(:jsonrpc "2.0" :id 9 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 11)))
[client-request] (id:10) Wed Feb 23 14:15:28 2022:
(:jsonrpc "2.0" :id 10 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 11)))
[server-reply] (id:8) Wed Feb 23 14:15:29 2022:
(:id 8 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
               []))
[server-reply] (id:9) Wed Feb 23 14:15:29 2022:
(:id 9 :jsonrpc "2.0" :result nil)
[server-notification] Wed Feb 23 14:15:29 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
      (:diagnostics
       []
       :uri "file:///tmp/a.c" :version 1))
[server-reply] (id:10) Wed Feb 23 14:15:29 2022:
(:id 10 :jsonrpc "2.0" :result
     [])
[stderr] I[14:15:28.983] <-- textDocument/didChange
[stderr] I[14:15:28.989] <-- textDocument/signatureHelp(8)
[stderr] I[14:15:28.992] <-- textDocument/hover(9)
[stderr] I[14:15:28.992] Failed to find compilation database for /tmp/a.c
[stderr] I[14:15:28.992] ASTWorker building file /tmp/a.c version 1 with command clangd fallback
[stderr] [/tmp]
[stderr] /usr/lib/llvm-13/bin/clang -resource-dir=redacted -- /tmp/a.c
[stderr] I[14:15:28.994] <-- textDocument/documentHighlight(10)
[stderr] I[14:15:28.995] --> reply:textDocument/signatureHelp(8) 5 ms
[stderr] I[14:15:28.998] --> reply:textDocument/hover(9) 6 ms
[stderr] I[14:15:28.998] Skipping rebuild of the AST for /tmp/a.c, inputs are the same.
[stderr] I[14:15:28.998] --> textDocument/publishDiagnostics
[stderr] I[14:15:28.998] --> reply:textDocument/documentHighlight(10) 4 ms
[client-request] (id:11) Wed Feb 23 14:15:30 2022:
(:jsonrpc "2.0" :id 11 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 11)))
[client-request] (id:12) Wed Feb 23 14:15:30 2022:
(:jsonrpc "2.0" :id 12 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 11)))
[client-request] (id:13) Wed Feb 23 14:15:30 2022:
(:jsonrpc "2.0" :id 13 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 11)))
[server-reply] (id:12) Wed Feb 23 14:15:30 2022:
(:id 12 :jsonrpc "2.0" :result nil)
[server-reply] (id:11) Wed Feb 23 14:15:30 2022:
(:id 11 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
               []))
[server-reply] (id:13) Wed Feb 23 14:15:30 2022:
(:id 13 :jsonrpc "2.0" :result
     [])
[stderr] I[14:15:30.754] <-- textDocument/signatureHelp(11)
[stderr] I[14:15:30.758] <-- textDocument/hover(12)
[stderr] I[14:15:30.759] --> reply:textDocument/hover(12) 0 ms
[stderr] I[14:15:30.759] --> reply:textDocument/signatureHelp(11) 4 ms
[stderr] I[14:15:30.910] <-- textDocument/documentHighlight(13)
[stderr] I[14:15:30.911] --> reply:textDocument/documentHighlight(13) 0 ms
[internal] (id:14) Wed Feb 23 14:15:31 2022:
(:deferring :textDocument/signatureHelp :id 14 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 12)))
[internal] (id:15) Wed Feb 23 14:15:31 2022:
(:deferring :textDocument/hover :id 15 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 12)))
[internal] (id:16) Wed Feb 23 14:15:31 2022:
(:deferring :textDocument/documentHighlight :id 16 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 12)))
[client-notification] Wed Feb 23 14:15:31 2022:
(:jsonrpc "2.0" :method "textDocument/didChange" :params
      (:textDocument
       (:uri "file:///tmp/a.c" :version 2)
       :contentChanges
       [(:range
         (:start
          (:line 1 :character 11)
          :end
          (:line 1 :character 11))
         :rangeLength 0 :text " ")]))
[internal] Wed Feb 23 14:15:31 2022:
(:maybe-run-deferred
 (16 15 14))
[client-request] (id:16) Wed Feb 23 14:15:31 2022:
(:jsonrpc "2.0" :id 16 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 12)))
[client-request] (id:15) Wed Feb 23 14:15:31 2022:
(:jsonrpc "2.0" :id 15 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 12)))
[client-request] (id:14) Wed Feb 23 14:15:31 2022:
(:jsonrpc "2.0" :id 14 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 1 :character 12)))
[server-reply] (id:16) Wed Feb 23 14:15:31 2022:
(:id 16 :jsonrpc "2.0" :result
     [])
[server-notification] Wed Feb 23 14:15:31 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
      (:diagnostics
       []
       :uri "file:///tmp/a.c" :version 2))
[stderr] I[14:15:31.476] <-- textDocument/didChange
[stderr] I[14:15:31.481] <-- textDocument/documentHighlight(16)
[stderr] I[14:15:31.481] Failed to find compilation database for /tmp/a.c
[stderr] I[14:15:31.481] ASTWorker building file /tmp/a.c version 2 with command clangd fallback
[stderr] [/tmp]
[stderr] /usr/lib/llvm-13/bin/clang -resource-dir=redacted -- /tmp/a.c
[stderr] I[14:15:31.483] <-- textDocument/hover(15)
[stderr] I[14:15:31.486] <-- textDocument/signatureHelp(14)
[stderr] I[14:15:31.489] --> reply:textDocument/documentHighlight(16) 7 ms
[stderr] I[14:15:31.489] Skipping rebuild of the AST for /tmp/a.c, inputs are the same.
[stderr] I[14:15:31.489] --> textDocument/publishDiagnostics
[stderr] I[14:15:31.489] --> reply:textDocument/hover(15) 5 ms
[stderr] I[14:15:31.489] --> reply:textDocument/signatureHelp(14) 3 ms
[internal] (id:8) Wed Feb 23 14:15:38 2022:
(:timed-out :textDocument/signatureHelp :id 8 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 11)))
[internal] (id:9) Wed Feb 23 14:15:38 2022:
(:timed-out :textDocument/hover :id 9 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 11)))
[internal] (id:10) Wed Feb 23 14:15:39 2022:
(:timed-out :textDocument/documentHighlight :id 10 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 11)))
[internal] (id:14) Wed Feb 23 14:15:41 2022:
(:timed-out :textDocument/signatureHelp :id 14 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 12)))
[internal] (id:15) Wed Feb 23 14:15:41 2022:
(:timed-out :textDocument/hover :id 15 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 12)))
[internal] (id:16) Wed Feb 23 14:15:41 2022:
(:timed-out :textDocument/documentHighlight :id 16 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 12)))
[internal] (id:15) Wed Feb 23 14:15:41 2022:
(:timed-out :textDocument/hover :id 15 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 12)))
[internal] (id:14) Wed Feb 23 14:15:41 2022:
(:timed-out :textDocument/signatureHelp :id 14 :params
        (:textDocument
         (:uri "file:///tmp/a.c")
         :position
         (:line 1 :character 12)))
[client-request] (id:17) Wed Feb 23 14:16:58 2022:
(:jsonrpc "2.0" :id 17 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 3 :character 0)))
[client-request] (id:18) Wed Feb 23 14:16:58 2022:
(:jsonrpc "2.0" :id 18 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 3 :character 0)))
[client-request] (id:19) Wed Feb 23 14:16:58 2022:
(:jsonrpc "2.0" :id 19 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///tmp/a.c")
       :position
       (:line 3 :character 0)))
[server-reply] (id:18) Wed Feb 23 14:16:58 2022:
(:id 18 :jsonrpc "2.0" :result nil)
[server-reply] (id:17) Wed Feb 23 14:16:58 2022:
(:id 17 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
               []))
[server-reply] (id:19) Wed Feb 23 14:16:58 2022:
(:id 19 :jsonrpc "2.0" :result
     [])
[stderr] I[14:16:58.210] <-- textDocument/signatureHelp(17)
[stderr] I[14:16:58.219] <-- textDocument/hover(18)
[stderr] I[14:16:58.219] --> reply:textDocument/hover(18) 0 ms
[stderr] I[14:16:58.223] --> reply:textDocument/signatureHelp(17) 13 ms
[stderr] I[14:16:58.226] <-- textDocument/documentHighlight(19)
[stderr] I[14:16:58.226] --> reply:textDocument/documentHighlight(19) 0 ms

Backtrace (mandatory, unless no error message seen or heard):

Debugger entered--Lisp error: (error "[Flymake] Obsolete report from backend eglot-flymake-backend with explanation nil")
  signal(error ("[Flymake] Obsolete report from backend eglot-flymake-backend with explanation nil"))
  error("[Flymake] Obsolete report from backend eglot-flymake-backend with explanation nil")
  flymake-error("Obsolete report from backend %s with explanation %s" eglot-flymake-backend nil)
  flymake--handle-report(eglot-flymake-backend backend-token20 nil :region (1 . 33))
  apply(flymake--handle-report eglot-flymake-backend backend-token20 (nil :region (1 . 33)))
  #f(compiled-function (&rest args) #<bytecode 0x15e2876702907aa7>)(nil :region (1 . 33))
  funcall(#f(compiled-function (&rest args) #<bytecode 0x15e2876702907aa7>) nil :region (1 . 33))
  (save-restriction (widen) (funcall eglot--current-flymake-report-fn diags :region (cons (point-min) (point-max))))
  eglot--report-to-flymake(nil)
  (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--unreported-diagnostics (cons t diags))))
  (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let ((object-once diag-spec)) (let* (... ... ... ... ... ...) (progn ... ... ...))))))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--unreported-diagnostics (cons t diags)))) nil)
  (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let (...) (let* ... ...)))))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--unreported-diagnostics (cons t diags)))) nil))
  (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let ... ...))))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--unreported-diagnostics (cons t diags)))) nil)) (let* ((path (expand-file-name (eglot--uri-to-path uri))) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let (...) (let* ... ...)))))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil))
  (let* ((buffer (and t (find-buffer-visiting (eglot--uri-to-path uri))))) (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list ...)))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--unreported-diagnostics (cons t diags)))) nil)) (let* ((path (expand-file-name (eglot--uri-to-path uri))) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let ... ...))))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil)))
  (progn (let* ((buffer (and t (find-buffer-visiting (eglot--uri-to-path uri))))) (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- ...) (< --cl-idx-- ...)) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags ...))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--unreported-diagnostics ...))) nil)) (let* ((path (expand-file-name (eglot--uri-to-path uri))) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list ...)))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil))))
  (let* ((--cl-eglot--diag-type-- #'(lambda (sev) (cond ((null sev) 'eglot-error) ((<= sev 1) 'eglot-error) ((= sev 2) 'eglot-warning) (t 'eglot-note))))) (progn (let* ((buffer (and t (find-buffer-visiting (eglot--uri-to-path uri))))) (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and ... ...) (setq diag-spec ...) (setq diags ...)) (cond (eglot--current-flymake-report-fn ...) (t ...)) nil)) (let* ((path (expand-file-name ...)) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- ...) (< --cl-idx-- ...)) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags ...))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil)))))
  (let* ((uri (car (cdr (plist-member --cl-rest-- ':uri)))) (diagnostics (car (cdr (plist-member --cl-rest-- ':diagnostics))))) (let* ((--cl-eglot--diag-type-- #'(lambda (sev) (cond (... ...) (... ...) (... ...) (t ...))))) (progn (let* ((buffer (and t (find-buffer-visiting ...)))) (if buffer (save-current-buffer (set-buffer buffer) (let* (... ... ... ...) (while ... ... ...) (cond ... ...) nil)) (let* ((path ...) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and ... ...) (setq diag-spec ...) (setq diags ...)) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics ...)) (setq flymake-list-only-diagnostics (cons ... flymake-list-only-diagnostics)) nil))))))
  (progn (let* ((uri (car (cdr (plist-member --cl-rest-- ':uri)))) (diagnostics (car (cdr (plist-member --cl-rest-- ':diagnostics))))) (let* ((--cl-eglot--diag-type-- #'(lambda (sev) (cond ... ... ... ...)))) (progn (let* ((buffer (and t ...))) (if buffer (save-current-buffer (set-buffer buffer) (let* ... ... ... nil)) (let* (... ... ... ... ...) (while ... ... ...) (setq flymake-list-only-diagnostics ...) (setq flymake-list-only-diagnostics ...) nil)))))))
  (closure (revert-buffer-preserve-modes eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) (_server _method &rest --cl-rest--) "Handle notification publishDiagnostics.\n\n(fn SERVE..." (progn (let* ((uri (car (cdr ...))) (diagnostics (car (cdr ...)))) (let* ((--cl-eglot--diag-type-- #'...)) (progn (let* (...) (if buffer ... ...)))))))(#<eglot-lsp-server eglot-lsp-server-1580d9f8e606> textDocument/publishDiagnostics :diagnostics [] :uri "file:///tmp/a.c" :version 2)
  apply((closure (revert-buffer-preserve-modes eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) (_server _method &rest --cl-rest--) "Handle notification publishDiagnostics.\n\n(fn SERVE..." (progn (let* ((uri (car (cdr ...))) (diagnostics (car (cdr ...)))) (let* ((--cl-eglot--diag-type-- #'...)) (progn (let* (...) (if buffer ... ...))))))) #<eglot-lsp-server eglot-lsp-server-1580d9f8e606> textDocument/publishDiagnostics (:diagnostics [] :uri "file:///tmp/a.c" :version 2))
  eglot-handle-notification(#<eglot-lsp-server eglot-lsp-server-1580d9f8e606> textDocument/publishDiagnostics :diagnostics [] :uri "file:///tmp/a.c" :version 2)
  apply(eglot-handle-notification #<eglot-lsp-server eglot-lsp-server-1580d9f8e606> textDocument/publishDiagnostics (:diagnostics [] :uri "file:///tmp/a.c" :version 2))
  (let ((eglot--cached-server server)) (apply fn server method (append params nil)))
  (closure ((fn . eglot-handle-notification) (initargs :process (closure ((contact "/usr/bin/clangd") (server-info "/usr/bin/clangd") (autostart-inferior-process) (readable-name . "EGLOT (tmp/c-mode)") (nickname . "tmp") (language-id . "c") (contact "/usr/bin/clangd") (class . eglot-lsp-server) (project transient . "/tmp/") (managed-major-mode . c-mode) eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) nil (let ((default-directory default-directory)) (make-process :name readable-name :command (setq server-info ...) :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create ...) :file-handler t)))) (contact "/usr/bin/clangd") (server-info "/usr/bin/clangd") (autostart-inferior-process) (readable-name . "EGLOT (tmp/c-mode)") (nickname . "tmp") (language-id . "c") (contact "/usr/bin/clangd") (class . eglot-lsp-server) (project transient . "/tmp/") (managed-major-mode . c-mode) eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) (server method params) (let ((eglot--cached-server server)) (apply fn server method (append params nil))))(#<eglot-lsp-server eglot-lsp-server-1580d9f8e606> textDocument/publishDiagnostics (:diagnostics [] :uri "file:///tmp/a.c" :version 2))
  jsonrpc-connection-receive(#<eglot-lsp-server eglot-lsp-server-1580d9f8e606> (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:diagnostics [] :uri "file:///tmp/a.c" :version 2)))
  jsonrpc--process-filter(#<process EGLOT (tmp/c-mode)> "Content-Length: 37\15\n\15\n{\"id\":16,\"jsonrpc\":\"2.0\",\"result\":[]}Content-Length: 124\15\n\15\n{\"jsonrpc\":\"2.0\",\"...")

Minimal configuration (mandatory)

 emacs -Q -f toggle-debug-on-error -l flymake -L ~/checkout/of/eglot/repo -l eglot.el /tmp/a.c -f flymake-mode -f eglot

No additional configuration, but ensure that clangd is installed. (The precise language server and version shouldn't matter, this appears to be an Eglot-internal problem.) Then, visit any C/C++ file (/tmp/a.c in my example), clone the buffer with C-x 4 c, and start typing in the cloned buffer. Flymake will immediately signal an error.

joaotavora commented 2 years ago

Thanks @phst for a "proper" reproduction recipe (at least the way I intended it)

I somehow suspectthis is a Flymake problem, not an Eglot problem, but if Eglot+clangd is useful in reproducing it, why not? :-)

Can you say when in your LSP log you typed C-x 4 c? Either say the time in relation to that log, or edit the transcript with a clear comment. Thanks

phst commented 2 years ago

Sorry for the delay, here's another transcript on a different machine (on macOS, but the symptoms are the same):

Before cloning the buffer:

[internal] Sat Apr 23 21:07:44 2022:
(:message "Running language server: (/usr/bin/clangd)")
[client-request] (id:1) Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :id 1 :method "initialize" :params
      (:processId 79116 :rootPath "/tmp/" :rootUri "file:///private/tmp" :initializationOptions #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                                          ())
              :capabilities
              (:workspace
               (:applyEdit t :executeCommand
                   (:dynamicRegistration :json-false)
                   :workspaceEdit
                   (:documentChanges t)
                   :didChangeWatchedFiles
                   (:dynamicRegistration t)
                   :symbol
                   (:dynamicRegistration :json-false)
                   :configuration t :workspaceFolders t)
               :textDocument
               (:synchronization
            (:dynamicRegistration :json-false :willSave t :willSaveWaitUntil t :didSave t)
            :completion
            (:dynamicRegistration :json-false :completionItem
                          (:snippetSupport :json-false :deprecatedSupport t :tagSupport
                                   (:valueSet
                                [1]))
                          :contextSupport t)
            :hover
            (:dynamicRegistration :json-false :contentFormat
                          ["plaintext"])
            :signatureHelp
            (:dynamicRegistration :json-false :signatureInformation
                          (:parameterInformation
                           (:labelOffsetSupport t)
                           :activeParameterSupport t))
            :references
            (:dynamicRegistration :json-false)
            :definition
            (:dynamicRegistration :json-false :linkSupport t)
            :declaration
            (:dynamicRegistration :json-false :linkSupport t)
            :implementation
            (:dynamicRegistration :json-false :linkSupport t)
            :typeDefinition
            (:dynamicRegistration :json-false :linkSupport t)
            :documentSymbol
            (:dynamicRegistration :json-false :hierarchicalDocumentSymbolSupport t :symbolKind
                          (:valueSet
                           [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26]))
            :documentHighlight
            (:dynamicRegistration :json-false)
            :codeAction
            (:dynamicRegistration :json-false :codeActionLiteralSupport
                          (:codeActionKind
                           (:valueSet
                        ["quickfix" "refactor" "refactor.extract" "refactor.inline" "refactor.rewrite" "source" "source.organizeImports"]))
                          :isPreferredSupport t)
            :formatting
            (:dynamicRegistration :json-false)
            :rangeFormatting
            (:dynamicRegistration :json-false)
            :rename
            (:dynamicRegistration :json-false)
            :publishDiagnostics
            (:relatedInformation :json-false :codeDescriptionSupport :json-false :tagSupport
                         (:valueSet
                          [1 2])))
               :experimental #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                           ()))
              :workspaceFolders
              [(:uri "file:///private/tmp" :name "/tmp/")]))
[stderr] I[21:07:44.572] Apple clangd version 13.1.6 (clang-1316.0.21.2.3)
[stderr] I[21:07:44.572] Features: mac+xpc
[stderr] I[21:07:44.572] PID: 79117
[stderr] I[21:07:44.572] Working directory: /tmp
[stderr] I[21:07:44.572] argv[0]: /Library/Developer/CommandLineTools/usr/bin/clangd
[stderr] I[21:07:44.572] Starting LSP over stdin/stdout
[stderr] I[21:07:44.572] <-- initialize(1)
[stderr] I[21:07:44.576] --> reply:initialize(1) 3 ms
[server-reply] (id:1) Sat Apr 23 21:07:44 2022:
(:id 1 :jsonrpc "2.0" :result
     (:capabilities
      (:astProvider t :callHierarchyProvider t :codeActionProvider
            (:codeActionKinds
             ["quickfix" "refactor" "info"])
            :compilationDatabase
            (:automaticReload t)
            :completionProvider
            (:allCommitCharacters
             [" " " " "(" ")" "[" "]" "{" "}" "<" ">" ":" ";" "," "+" "-" "/" "*" "%" "^" "&" "#" "?" "." "=" "\"" "'" "|"]
             :resolveProvider :json-false :triggerCharacters
             ["." "<" ">" ":" "\"" "/"])
            :declarationProvider t :definitionProvider t :documentFormattingProvider t :documentHighlightProvider t :documentLinkProvider
            (:resolveProvider :json-false)
            :documentOnTypeFormattingProvider
            (:firstTriggerCharacter "\n" :moreTriggerCharacter
                        [])
            :documentRangeFormattingProvider t :documentSymbolProvider t :executeCommandProvider
            (:commands
             ["clangd.applyFix" "clangd.applyTweak"])
            :hoverProvider t :implementationProvider t :memoryUsageProvider t :referencesProvider t :renameProvider t :selectionRangeProvider t :semanticTokensProvider
            (:full
             (:delta t)
             :legend
             (:tokenModifiers
              ["declaration" "deprecated" "deduced" "readonly" "static" "abstract" "dependentName" "defaultLibrary" "functionScope" "classScope" "fileScope" "globalScope"]
              :tokenTypes
              ["variable" "variable" "parameter" "function" "method" "function" "property" "variable" "class" "interface" "enum" "enumMember" "type" "type" "unknown" "namespace" "typeParameter" "concept" "type" "macro" "comment"])
             :range :json-false)
            :signatureHelpProvider
            (:triggerCharacters
             ["(" ","])
            :textDocumentSync
            (:change 2 :openClose t :save t)
            :typeHierarchyProvider t :workspaceSymbolProvider t)
      :serverInfo
      (:name "clangd" :version "Apple clangd version 13.1.6 (clang-1316.0.21.2.3) mac+xpc")))
[client-notification] Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :method "initialized" :params #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8125 data
                                ()))
[client-notification] Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :method "textDocument/didOpen" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c" :version 0 :languageId "c" :text "")))
[client-notification] Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :method "workspace/didChangeConfiguration" :params
      (:settings nil))
[server-notification] Sat Apr 23 21:07:44 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
      (:diagnostics
       []
       :uri "file:///private/tmp/a.c" :version 0))
[stderr] I[21:07:44.591] <-- initialized
[stderr] I[21:07:44.591] <-- textDocument/didOpen
[stderr] I[21:07:44.591] Failed to find compilation database for /private/tmp/a.c
[stderr] I[21:07:44.591] ASTWorker building file /private/tmp/a.c version 0 with command clangd fallback
[stderr] [/private/tmp]
[stderr] /Library/Developer/CommandLineTools/usr/bin/clang /private/tmp/a.c -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6
[stderr] I[21:07:44.601] <-- workspace/didChangeConfiguration
[stderr] I[21:07:44.608] --> textDocument/publishDiagnostics
[client-request] (id:2) Sat Apr 23 21:07:45 2022:
(:jsonrpc "2.0" :id 2 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 0)))
[client-request] (id:3) Sat Apr 23 21:07:45 2022:
(:jsonrpc "2.0" :id 3 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 0)))
[client-request] (id:4) Sat Apr 23 21:07:45 2022:
(:jsonrpc "2.0" :id 4 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 0)))
[server-reply] (id:3) Sat Apr 23 21:07:45 2022:
(:id 3 :jsonrpc "2.0" :result nil)
[server-reply] (id:4) Sat Apr 23 21:07:45 2022:
(:id 4 :jsonrpc "2.0" :result
     [])
[stderr] I[21:07:45.172] <-- textDocument/signatureHelp(2)
[stderr] I[21:07:45.173] <-- textDocument/hover(3)
[stderr] I[21:07:45.174] --> reply:textDocument/hover(3) 0 ms
[stderr] I[21:07:45.174] <-- textDocument/documentHighlight(4)
[stderr] I[21:07:45.174] --> reply:textDocument/documentHighlight(4) 0 ms
[server-reply] (id:2) Sat Apr 23 21:07:45 2022:
(:id 2 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
               []))
[stderr] I[21:07:45.185] --> reply:textDocument/signatureHelp(2) 12 ms

After cloning the buffer, before typing:

[client-request] (id:5) Sat Apr 23 21:08:35 2022:
(:jsonrpc "2.0" :id 5 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 0)))
[client-request] (id:6) Sat Apr 23 21:08:35 2022:
(:jsonrpc "2.0" :id 6 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 0)))
[client-request] (id:7) Sat Apr 23 21:08:35 2022:
(:jsonrpc "2.0" :id 7 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 0)))
[server-reply] (id:6) Sat Apr 23 21:08:35 2022:
(:id 6 :jsonrpc "2.0" :result nil)
[server-reply] (id:7) Sat Apr 23 21:08:35 2022:
(:id 7 :jsonrpc "2.0" :result
     [])
[stderr] I[21:08:35.041] <-- textDocument/signatureHelp(5)
[stderr] I[21:08:35.042] <-- textDocument/hover(6)
[stderr] I[21:08:35.042] --> reply:textDocument/hover(6) 0 ms
[stderr] I[21:08:35.042] <-- textDocument/documentHighlight(7)
[stderr] I[21:08:35.042] --> reply:textDocument/documentHighlight(7) 0 ms
[server-reply] (id:5) Sat Apr 23 21:08:35 2022:
(:id 5 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
               []))
[stderr] I[21:08:35.053] --> reply:textDocument/signatureHelp(5) 12 ms

After typing and getting the error:

[internal] (id:8) Sat Apr 23 21:09:15 2022:
(:deferring :textDocument/signatureHelp :id 8 :params
        (:textDocument
         (:uri "file:///private/tmp/a.c")
         :position
         (:line 0 :character 1)))
[internal] (id:9) Sat Apr 23 21:09:15 2022:
(:deferring :textDocument/hover :id 9 :params
        (:textDocument
         (:uri "file:///private/tmp/a.c")
         :position
         (:line 0 :character 1)))
[internal] (id:10) Sat Apr 23 21:09:15 2022:
(:deferring :textDocument/documentHighlight :id 10 :params
        (:textDocument
         (:uri "file:///private/tmp/a.c")
         :position
         (:line 0 :character 1)))
[client-notification] Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :method "textDocument/didChange" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c" :version 1)
       :contentChanges
       [(:range
         (:start
          (:line 0 :character 0)
          :end
          (:line 0 :character 0))
         :rangeLength 0 :text "a")]))
[internal] Sat Apr 23 21:09:15 2022:
(:maybe-run-deferred
 (8 9 10))
[client-request] (id:8) Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :id 8 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 1)))
[client-request] (id:9) Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :id 9 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 1)))
[client-request] (id:10) Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :id 10 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 1)))
[stderr] I[21:09:15.455] <-- textDocument/didChange
[stderr] I[21:09:15.455] <-- textDocument/signatureHelp(8)
[stderr] I[21:09:15.456] <-- textDocument/hover(9)
[stderr] I[21:09:15.456] <-- textDocument/documentHighlight(10)
[stderr] I[21:09:15.456] Failed to find compilation database for /private/tmp/a.c
[stderr] I[21:09:15.456] ASTWorker building file /private/tmp/a.c version 1 with command clangd fallback
[stderr] [/private/tmp]
[stderr] /Library/Developer/CommandLineTools/usr/bin/clang /private/tmp/a.c -resource-dir=/Library/Developer/CommandLineTools/usr/lib/clang/13.1.6
[server-reply] (id:8) Sat Apr 23 21:09:15 2022:
(:id 8 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
               []))
[stderr] I[21:09:15.465] --> reply:textDocument/signatureHelp(8) 9 ms
[server-reply] (id:9) Sat Apr 23 21:09:15 2022:
(:id 9 :jsonrpc "2.0" :result nil)
[server-reply] (id:10) Sat Apr 23 21:09:15 2022:
(:id 10 :jsonrpc "2.0" :result
     [])
[server-notification] Sat Apr 23 21:09:15 2022:
(:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params
      (:diagnostics
       [(:code "unknown_typename" :message "Unknown type name 'a'" :range
           (:end
            (:character 1 :line 0)
            :start
            (:character 0 :line 0))
           :severity 1 :source "clang")
        (:code "expected_either" :message "Expected identifier or '('" :range
           (:end
            (:character 1 :line 0)
            :start
            (:character 1 :line 0))
           :severity 1 :source "clang")]
       :uri "file:///private/tmp/a.c" :version 1))
[stderr] I[21:09:15.471] --> reply:textDocument/hover(9) 15 ms
[stderr] I[21:09:15.471] --> reply:textDocument/documentHighlight(10) 14 ms
[stderr] I[21:09:15.487] --> textDocument/publishDiagnostics
[client-request] (id:11) Sat Apr 23 21:09:18 2022:
(:jsonrpc "2.0" :id 11 :method "textDocument/signatureHelp" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 1)))
[client-request] (id:12) Sat Apr 23 21:09:18 2022:
(:jsonrpc "2.0" :id 12 :method "textDocument/hover" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 1)))
[client-request] (id:13) Sat Apr 23 21:09:18 2022:
(:jsonrpc "2.0" :id 13 :method "textDocument/documentHighlight" :params
      (:textDocument
       (:uri "file:///private/tmp/a.c")
       :position
       (:line 0 :character 1)))
[server-reply] (id:12) Sat Apr 23 21:09:18 2022:
(:id 12 :jsonrpc "2.0" :result nil)
[server-reply] (id:13) Sat Apr 23 21:09:18 2022:
(:id 13 :jsonrpc "2.0" :result
     [])
[stderr] I[21:09:18.050] <-- textDocument/signatureHelp(11)
[stderr] I[21:09:18.051] <-- textDocument/hover(12)
[stderr] I[21:09:18.051] --> reply:textDocument/hover(12) 0 ms
[stderr] I[21:09:18.052] <-- textDocument/documentHighlight(13)
[stderr] I[21:09:18.052] --> reply:textDocument/documentHighlight(13) 0 ms
[server-reply] (id:11) Sat Apr 23 21:09:18 2022:
(:id 11 :jsonrpc "2.0" :result
     (:activeParameter 0 :activeSignature 0 :signatures
               []))
[stderr] I[21:09:18.060] --> reply:textDocument/signatureHelp(11) 10 ms
[internal] (id:8) Sat Apr 23 21:09:25 2022:
(:timed-out :textDocument/signatureHelp :id 8 :params
        (:textDocument
         (:uri "file:///private/tmp/a.c")
         :position
         (:line 0 :character 1)))
[internal] (id:9) Sat Apr 23 21:09:25 2022:
(:timed-out :textDocument/hover :id 9 :params
        (:textDocument
         (:uri "file:///private/tmp/a.c")
         :position
         (:line 0 :character 1)))
[internal] (id:10) Sat Apr 23 21:09:25 2022:
(:timed-out :textDocument/documentHighlight :id 10 :params
        (:textDocument
         (:uri "file:///private/tmp/a.c")
         :position
         (:line 0 :character 1)))

Here's a corresponding backtrace:

Debugger entered--Lisp error: (error "[Flymake] Obsolete report from backend eglot-flyma...")
  signal(error ("[Flymake] Obsolete report from backend eglot-flyma..."))
  error("[Flymake] Obsolete report from backend eglot-flyma...")
  flymake-error("Obsolete report from backend %s with explanation %..." eglot-flymake-backend nil)
  flymake--handle-report(eglot-flymake-backend backend-token19 (#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)) :region (1 . 3))
  apply(flymake--handle-report eglot-flymake-backend backend-token19 ((#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)) :region (1 . 3)))
  #f(compiled-function (&rest args) #<bytecode -0x1d787f877e6e25dc>)((#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)) :region (1 . 3))
  funcall(#f(compiled-function (&rest args) #<bytecode -0x1d787f877e6e25dc>) (#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)) :region (1 . 3))
  (save-restriction (widen) (funcall eglot--current-flymake-report-fn diags :region (cons (point-min) (point-max))))
  eglot--report-to-flymake((#s(flymake--diag :locus #<buffer a.c> :beg 1 :end 3 :type eglot-error :text "clang: Unknown type name 'aa'" :backend nil :data ((eglot-lsp-diag :code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 1 :orig-end 3) #s(flymake--diag :locus #<buffer a.c> :beg 2 :end 3 :type eglot-error :text "clang: Expected identifier or '('" :backend nil :data ((eglot-lsp-diag :code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")) :overlay-properties nil :overlay nil :orig-beg 2 :orig-end 3)))
  (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags)))
  (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let ((object-once diag-spec)) (let* (... ... ... ... ... ...) (progn ... ... ...))))))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil)
  (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let (...) (let* ... ...)))))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil))
  (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let ... ...))))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil)) (let* ((path (expand-file-name (eglot--uri-to-path uri))) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let (...) (let* ... ...)))))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil))
  (let* ((buffer (and t (find-buffer-visiting (eglot--uri-to-path uri))))) (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list ...)))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil)) (let* ((path (expand-file-name (eglot--uri-to-path uri))) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list (let ... ...))))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil)))
  (progn (let* ((buffer (and t (find-buffer-visiting (eglot--uri-to-path uri))))) (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- ...) (< --cl-idx-- ...)) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags ...))) (cond (eglot--current-flymake-report-fn (eglot--report-to-flymake diags)) (t (setq eglot--diagnostics diags))) nil)) (let* ((path (expand-file-name (eglot--uri-to-path uri))) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- (1+ --cl-idx--)) (< --cl-idx-- (length --cl-vec--))) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags (list ...)))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil))))
  (let* ((--cl-eglot--diag-type-- #'(lambda (sev) (cond ((null sev) 'eglot-error) ((<= sev 1) 'eglot-error) ((= sev 2) 'eglot-warning) (t 'eglot-note))))) (progn (let* ((buffer (and t (find-buffer-visiting (eglot--uri-to-path uri))))) (if buffer (save-current-buffer (set-buffer buffer) (let* ((--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and ... ...) (setq diag-spec ...) (setq diags ...)) (cond (eglot--current-flymake-report-fn ...) (t ...)) nil)) (let* ((path (expand-file-name ...)) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and (setq --cl-idx-- ...) (< --cl-idx-- ...)) (setq diag-spec (aref --cl-vec-- --cl-idx--)) (setq diags (nconc diags ...))) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics #'string=)) (setq flymake-list-only-diagnostics (cons (cons path diags) flymake-list-only-diagnostics)) nil)))))
  (let* ((uri (car (cdr (plist-member --cl-rest-- ':uri)))) (diagnostics (car (cdr (plist-member --cl-rest-- ':diagnostics))))) (let* ((--cl-eglot--diag-type-- #'(lambda (sev) (cond (... ...) (... ...) (... ...) (t ...))))) (progn (let* ((buffer (and t (find-buffer-visiting ...)))) (if buffer (save-current-buffer (set-buffer buffer) (let* (... ... ... ...) (while ... ... ...) (cond ... ...) nil)) (let* ((path ...) (--cl-vec-- diagnostics) (--cl-idx-- -1) (diag-spec nil) (diags nil)) (while (and ... ...) (setq diag-spec ...) (setq diags ...)) (setq flymake-list-only-diagnostics (assoc-delete-all path flymake-list-only-diagnostics ...)) (setq flymake-list-only-diagnostics (cons ... flymake-list-only-diagnostics)) nil))))))
  (progn (let* ((uri (car (cdr (plist-member --cl-rest-- ':uri)))) (diagnostics (car (cdr (plist-member --cl-rest-- ':diagnostics))))) (let* ((--cl-eglot--diag-type-- #'(lambda (sev) (cond ... ... ... ...)))) (progn (let* ((buffer (and t ...))) (if buffer (save-current-buffer (set-buffer buffer) (let* ... ... ... nil)) (let* (... ... ... ... ...) (while ... ... ...) (setq flymake-list-only-diagnostics ...) (setq flymake-list-only-diagnostics ...) nil)))))))
  (closure (revert-buffer-preserve-modes eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) (_server _method &rest --cl-rest--) "Handle notification publishDiagnostics.\n\n(fn SERVE..." (progn (let* ((uri (car (cdr ...))) (diagnostics (car (cdr ...)))) (let* ((--cl-eglot--diag-type-- #'...)) (progn (let* (...) (if buffer ... ...)))))))(#<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics :diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2)
  apply((closure (revert-buffer-preserve-modes eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) (_server _method &rest --cl-rest--) "Handle notification publishDiagnostics.\n\n(fn SERVE..." (progn (let* ((uri (car (cdr ...))) (diagnostics (car (cdr ...)))) (let* ((--cl-eglot--diag-type-- #'...)) (progn (let* (...) (if buffer ... ...))))))) #<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics (:diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2))
  eglot-handle-notification(#<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics :diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2)
  apply(eglot-handle-notification #<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics (:diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2))
  (let ((eglot--cached-server server)) (apply fn server method (append params nil)))
  (closure ((fn . eglot-handle-notification) (initargs :process (closure ((contact "/usr/bin/clangd") (more-initargs) (probe) (contact "/usr/bin/clangd") (server-info "/usr/bin/clangd") (autostart-inferior-process) (readable-name . "EGLOT (tmp/c-mode)") (nickname . "tmp") (language-id . "c") (contact "/usr/bin/clangd") (class . eglot-lsp-server) (project transient . "/tmp/") (managed-major-mode . c-mode) eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) nil (let ((default-directory default-directory)) (make-process :name readable-name :command (setq server-info ...) :connection-type 'pipe :coding 'utf-8-emacs-unix :noquery t :stderr (get-buffer-create ...) :file-handler t)))) (contact "/usr/bin/clangd") (server-info "/usr/bin/clangd") (autostart-inferior-process) (readable-name . "EGLOT (tmp/c-mode)") (nickname . "tmp") (language-id . "c") (contact "/usr/bin/clangd") (class . eglot-lsp-server) (project transient . "/tmp/") (managed-major-mode . c-mode) eglot--managed-mode eglot-lsp-context company-tooltip-align-annotations company-backends markdown-fontify-code-blocks-natively t) (server method params) (let ((eglot--cached-server server)) (apply fn server method (append params nil))))(#<eglot-lsp-server eglot-lsp-server-4c135e32> textDocument/publishDiagnostics (:diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2))
  jsonrpc-connection-receive(#<eglot-lsp-server eglot-lsp-server-4c135e32> (:jsonrpc "2.0" :method "textDocument/publishDiagnostics" :params (:diagnostics [(:code "unknown_typename" :message "Unknown type name 'aa'" :range (:end (:character 2 :line 0) :start (:character 0 :line 0)) :severity 1 :source "clang") (:code "expected_either" :message "Expected identifier or '('" :range (:end (:character 2 :line 0) :start (:character 2 :line 0)) :severity 1 :source "clang")] :uri "file:///private/tmp/a.c" :version 2)))
  jsonrpc--process-filter(#<process EGLOT (tmp/c-mode)> "Content-Length: 37\15\n\15\n{\"id\":16,\"jsonrpc\":\"2.0\",\"re...")
Eason0210 commented 2 years ago

Can you say when in your LSP log you typed C-x 4 c?

I can reproduce this issue. I think what @phst means is : execute M-x, clone-indirect-buffer-other-window ( C-x 4 c ) in test.c buffer, and will create a test.c<2> buffer. Then edit thetest.c<2> buffer you will get error.

I tested it with latest commit of emacs 29.0.50 on macOS, with latest eglot.

sebasmonia commented 11 months ago

I sometimes use indirect buffers to edit a single function and ran into this problem too. Just adding a +1.