emacs-diffs
[Top][All Lists]
Advanced

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

master ab9c064 4/5: Move warnings about bad let-bindings from source opt


From: Mattias Engdegård
Subject: master ab9c064 4/5: Move warnings about bad let-bindings from source optimiser to cconv
Date: Fri, 30 Jul 2021 04:54:07 -0400 (EDT)

branch: master
commit ab9c06449df4c4c58d586573003de419199cc1be
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Move warnings about bad let-bindings from source optimiser to cconv
    
    * lisp/emacs-lisp/byte-opt.el (byte-optimize-let-form): Move warnings...
    * lisp/emacs-lisp/cconv.el (cconv-convert): ...here, which is an
    overall better place (closer to the front-end).
---
 lisp/emacs-lisp/byte-opt.el | 15 +++++----------
 lisp/emacs-lisp/cconv.el    |  7 +++++++
 2 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el
index b6052d8..c9dfa69 100644
--- a/lisp/emacs-lisp/byte-opt.el
+++ b/lisp/emacs-lisp/byte-opt.el
@@ -697,16 +697,11 @@ Same format as `byte-optimize--lexvars', with shared 
structure and contents.")
              (let-vars nil))
         (dolist (binding (car form))
           (let (name expr)
-            (cond ((consp binding)
-                   (setq name (car binding))
-                   (unless (symbolp name)
-                     (byte-compile-warn "let-bind nonvariable: `%S'" name))
-                   (setq expr (byte-optimize-form (cadr binding) nil)))
-                  ((symbolp binding)
-                   (setq name binding))
-                  (t (byte-compile-warn "malformed let binding: `%S'" 
binding)))
-            (let* (
-                   (value (and (byte-optimize--substitutable-p expr)
+            (if (atom binding)
+                (setq name binding)
+              (setq name (car binding))
+              (setq expr (byte-optimize-form (cadr binding) nil)))
+            (let* ((value (and (byte-optimize--substitutable-p expr)
                                (list expr)))
                    (lexical (not (or (and (symbolp name)
                                           (special-variable-p name))
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index ea0b098..e079597 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -358,6 +358,13 @@ places where they originally did not directly appear."
                           letsym binder))
                       (setq value (cadr binder))
                       (car binder)))
+                (_ (cond
+                    ((not (symbolp var))
+                     (byte-compile-warn "attempt to let-bind nonvariable `%S'"
+                                        var))
+                    ((or (booleanp var) (keywordp var))
+                     (byte-compile-warn "attempt to let-bind constant `%S'"
+                                        var))))
                (new-val
                 (pcase (cconv--var-classification binder form)
                    ;; Check if var is a candidate for lambda lifting.



reply via email to

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