diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2023-10-15 22:01:06 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2023-10-21 15:12:55 +0200 |
commit | a3db503351e9a8720cdea2f1ca42d55d2de684e2 (patch) | |
tree | 299791970977df508b580a64040e86f7e1f30782 /lisp/emacs-lisp/bytecomp.el | |
parent | 12c8cdb60cc41fb17a85c7e3f75f91cca2d60483 (diff) | |
download | emacs-a3db503351e9a8720cdea2f1ca42d55d2de684e2.tar.gz emacs-a3db503351e9a8720cdea2f1ca42d55d2de684e2.tar.bz2 emacs-a3db503351e9a8720cdea2f1ca42d55d2de684e2.zip |
Move lexical-binding warning from checkdoc to byte-compiler
This warning is much more appropriate for the compiler, since lexical
binding affects what it can reason and warn about, than for checkdoc
as the warning has no bearing to documentation at all.
The move also improves the reach of the warning.
* etc/NEWS: Update.
* lisp/emacs-lisp/checkdoc.el (checkdoc-lexical-binding-flag)
(checkdoc-file-comments-engine): Move warning from here....
* lisp/emacs-lisp/bytecomp.el (byte-compile-file): ...to here.
* test/lisp/emacs-lisp/bytecomp-resources/no-byte-compile.el:
* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--unescaped-char-literals)
(bytecomp-tests-function-put, bytecomp-tests--not-writable-directory)
(bytecomp-tests--target-file-no-directory):
Update tests.
(bytecomp-tests--log-from-compilation)
(bytecomp-tests--lexical-binding-cookie): New test.
Diffstat (limited to 'lisp/emacs-lisp/bytecomp.el')
-rw-r--r-- | lisp/emacs-lisp/bytecomp.el | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 92abe6b4624..cc68db73c9f 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -2201,6 +2201,10 @@ See also `emacs-lisp-byte-compile-and-load'." filename buffer-file-name)) ;; Don't inherit lexical-binding from caller (bug#12938). (unless (local-variable-p 'lexical-binding) + (let ((byte-compile-current-buffer (current-buffer))) + (byte-compile-warn-x + (position-symbol 'a (point-min)) + "file has no `lexical-binding' directive on its first line")) (setq-local lexical-binding nil)) ;; Set the default directory, in case an eval-when-compile uses it. (setq default-directory (file-name-directory filename))) |