emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/js2-mode 997d6bd 30/61: Avoid undefined behavior in ind


From: Dmitry Gutov
Subject: [elpa] externals/js2-mode 997d6bd 30/61: Avoid undefined behavior in indentation tests.
Date: Sun, 20 Dec 2020 12:20:04 -0500 (EST)

branch: externals/js2-mode
commit 997d6bd13565acd8710b6382d65d5ffb31e4f003
Author: Philipp Stephani <phst@google.com>
Commit: Philipp Stephani <phst@google.com>

    Avoid undefined behavior in indentation tests.
    
    Info node ‘(elisp) Local Variables’ states:
    
    > […] the order of _bindings_ is unspecified: […] Therefore, avoid binding a
    > variable more than once in a single ‘let’ form.
    
    In fact, the tests that bind ‘js2-pretty-multiline-declarations’ twice fail 
if
    indent.el is byte-compiled.
---
 tests/indent.el | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/indent.el b/tests/indent.el
index 0924691..57db7cf 100644
--- a/tests/indent.el
+++ b/tests/indent.el
@@ -39,11 +39,14 @@
 
 (cl-defmacro js2-deftest-indent (name content &key bind keep-indent)
   `(ert-deftest ,(intern (format "js2-%s" name)) ()
-     (let ,(append '(indent-tabs-mode
-                     (js2-basic-offset 2)
-                     (js2-pretty-multiline-declarations t)
-                     (inhibit-point-motion-hooks t))
-                   bind)
+     ;; We use ‘let*’ instead of ‘let’ in case a binding in BIND overwrites one
+     ;; of the outer bindings.  See the note about duplicate bindings in the
+     ;; Info node ‘(elisp) Local Variables’.
+     (let* ,(append '(indent-tabs-mode
+                      (js2-basic-offset 2)
+                      (js2-pretty-multiline-declarations t)
+                      (inhibit-point-motion-hooks t))
+                    bind)
        (js2-test-indent ,content ,keep-indent))))
 
 (put 'js2-deftest-indent 'lisp-indent-function 'defun)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]