Stefan Monnier writes: > > diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el > > index 966990bac9..418070fabe 100644 > > --- a/lisp/emacs-lisp/bytecomp.el > > +++ b/lisp/emacs-lisp/bytecomp.el > > @@ -3357,6 +3357,7 @@ byte-compile-check-variable > > (and od > > (not (memq var byte-compile-not-obsolete-vars)) > > (not (memq var byte-compile-global-not-obsolete-vars)) > > + (not (memq var byte-compile-lexical-variables)) > > (or (pcase (nth 1 od) > > ('set (not (eq access-type 'reference))) > > ('get (eq access-type 'reference)) > > Yes! Coming back to this now... Ok, then let's do that! > > BTW, while I looked at this, I found this spurious lookup in > > `byte-compile-lexical-variables': > > > > #+begin_src emacs-lisp > > (defun byte-compile-form (form &optional for-effect) > > (let ((byte-compile--for-effect for-effect)) > > (cond > > ((not (consp form))..10..) > > ((symbolp (car form)) > > (let* ((fn (car form))..4..) > > (when (memq fn '(set symbol-value run-hooks..4..) > > (pcase (cdr form) > > (`(',var . ,_) > > (when (assq var byte-compile-lexical-variables) ;; <--- here > > (byte-compile-report-error > > (format-message "%s cannot use lexical var `%s'" fn var))) > > ...))))))))) > > #+end_src > > > > shouldn't the `assq' be `memq'? > > I think you're right. Seems this has been treated meanwhile: Bug#44980 and commit ace6eba036 "Fix byte-compiler warning for failed uses of lexical vars", Stefan Kangas. > Both changes should ideally come with corresponding regression tests. I tried to add an appropriate test for the remaining case, please check the following patch (my first addition to the test suite) - is it what you had in mind? - where I also try to give a less confusing (but longer) compiler warning. Does it look alright?