Skip to content

Commit 0026d0b

Browse files
committed
Don't keep warning about unescaped literals (Bug#36068)
* lisp/emacs-lisp/bytecomp.el (byte-compile-from-buffer): Restore lost let-binding of lread--unescaped-character-literals, so that unescaped literals warning will only apply to the form just read. * test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-tests--unescaped-char-literals): Expand test to check that we don't keep warning about old unescaped literals.
1 parent 03b66d2 commit 0026d0b

File tree

2 files changed

+22
-15
lines changed

2 files changed

+22
-15
lines changed

lisp/emacs-lisp/bytecomp.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2093,8 +2093,9 @@ With argument ARG, insert value in current buffer after the form."
20932093
(not (eobp)))
20942094
(setq byte-compile-read-position (point)
20952095
byte-compile-last-position byte-compile-read-position)
2096-
(let ((form (read inbuffer))
2097-
(warning (byte-run--unescaped-character-literals-warning)))
2096+
(let* ((lread--unescaped-character-literals nil)
2097+
(form (read inbuffer))
2098+
(warning (byte-run--unescaped-character-literals-warning)))
20982099
(when warning (byte-compile-warn "%s" warning))
20992100
(byte-compile-toplevel-file-form form)))
21002101
;; Compile pending forms at end of file.

test/lisp/emacs-lisp/bytecomp-tests.el

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -559,19 +559,25 @@ bytecompiled code, and their results compared.")
559559
"Check that byte compiling warns about unescaped character
560560
literals (Bug#20852)."
561561
(should (boundp 'lread--unescaped-character-literals))
562-
(bytecomp-tests--with-temp-file source
563-
(write-region "(list ?) ?( ?; ?\" ?[ ?])" nil source)
564-
(bytecomp-tests--with-temp-file destination
565-
(let* ((byte-compile-dest-file-function (lambda (_) destination))
566-
(byte-compile-error-on-warn t)
567-
(byte-compile-debug t)
568-
(err (should-error (byte-compile-file source))))
569-
(should (equal (cdr err)
570-
(list (concat "unescaped character literals "
571-
"`?\"', `?(', `?)', `?;', `?[', `?]' "
572-
"detected, "
573-
"`?\\\"', `?\\(', `?\\)', `?\\;', `?\\[', "
574-
"`?\\]' expected!"))))))))
562+
(let ((byte-compile-error-on-warn t)
563+
(byte-compile-debug t))
564+
(bytecomp-tests--with-temp-file source
565+
(write-region "(list ?) ?( ?; ?\" ?[ ?])" nil source)
566+
(bytecomp-tests--with-temp-file destination
567+
(let* ((byte-compile-dest-file-function (lambda (_) destination))
568+
(err (should-error (byte-compile-file source))))
569+
(should (equal (cdr err)
570+
`(,(concat "unescaped character literals "
571+
"`?\"', `?(', `?)', `?;', `?[', `?]' "
572+
"detected, "
573+
"`?\\\"', `?\\(', `?\\)', `?\\;', `?\\[', "
574+
"`?\\]' expected!")))))))
575+
;; But don't warn in subsequent compilations (Bug#36068).
576+
(bytecomp-tests--with-temp-file source
577+
(write-region "(list 1 2 3)" nil source)
578+
(bytecomp-tests--with-temp-file destination
579+
(let ((byte-compile-dest-file-function (lambda (_) destination)))
580+
(should (byte-compile-file source)))))))
575581

576582
(ert-deftest bytecomp-tests--old-style-backquotes ()
577583
"Check that byte compiling warns about old-style backquotes."

0 commit comments

Comments
 (0)