-
Notifications
You must be signed in to change notification settings - Fork 202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flymake backend signals errors ("obsolete report") when editing code in an indirect/cloned buffer #843
Comments
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 |
Sorry for the delay, here's another transcript on a different machine (on macOS, but the symptoms are the same): Before cloning the buffer:
After cloning the buffer, before typing:
After typing and getting the error:
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...") |
I can reproduce this issue. I think what @phst means is : execute I tested it with latest commit of emacs 29.0.50 on macOS, with latest eglot. |
I sometimes use indirect buffers to edit a single function and ran into this problem too. Just adding a +1. |
emacs -Q -l eglot.el
from a checkout of this repository.LSP transcript - M-x eglot-events-buffer (mandatory unless Emacs inoperable)
Backtrace (mandatory, unless no error message seen or heard):
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.
The text was updated successfully, but these errors were encountered: