]> git.eshelyaron.com Git - emacs.git/commitdiff
Fail earlier if stale Flymake report functions called
authorJoão Távora <joaotavora@gmail.com>
Sat, 10 Apr 2021 10:19:26 +0000 (11:19 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sat, 10 Apr 2021 10:19:34 +0000 (11:19 +0100)
If a Flymake backend calls a "stale" report function,
flymake--handle-report might be called for a backend function that is
no longer in the flymake--backend-state hash table.  This patch makes
that erroneous situation slightly more explicit.

* lisp/progmodes/flymake.el (flymake--handle-report): Improve
error reporting.

lisp/progmodes/flymake.el

index 8481a27775fa722c861dbdbc2bc7c5a4fac55779..e10602ab0814231817534e2b6a6cd66110d1181f 100644 (file)
@@ -741,7 +741,10 @@ to handle a report even if TOKEN was not expected.  REGION is
 a (BEG . END) pair of buffer positions indicating that this
 report applies to that region."
   (let* ((state (gethash backend flymake--backend-state))
-         (first-report (not (flymake--backend-state-reported-p state))))
+         first-report)
+    (unless state
+      (error "Can't find state for %s in `flymake--backend-state'" backend))
+    (setf first-report (not (flymake--backend-state-reported-p state)))
     (setf (flymake--backend-state-reported-p state) t)
     (let (expected-token
           new-diags)