emacs-diffs
[Top][All Lists]
Advanced

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

master 0228421e349 1/3: Allow suppressing the "lexical arg shadows dynbo


From: Stefan Monnier
Subject: master 0228421e349 1/3: Allow suppressing the "lexical arg shadows dynbound var" warning
Date: Sun, 25 Jun 2023 11:39:14 -0400 (EDT)

branch: master
commit 0228421e349e77c00108ea9f6927285a6d04f4b5
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Allow suppressing the "lexical arg shadows dynbound var" warning
    
    In most cases the right way to fix this warning is by renaming
    the offending argument, but in some cases this is inconvenient, as is
    the case in `cl-defstruct` where arg names are imposed by slot names.
    
    This patch also happens to fix a few bugs along the way:
    - miscompilation of (lambda (gcs-done) (lambda (x) (+ x gcs-done)))
    - errors about void function `byte-compile-warn-x` if the warning was
      emitted via `cconv-fv` when bytecomp was not loaded.
    Oh, and it improves the warning by making the location info slightly
    more precise.
    
    * lisp/emacs-lisp/cconv.el (cconv--analyze-function): Remove this warning.
    * lisp/emacs-lisp/bytecomp.el (byte-compile-check-lambda-list):
    Warn about it here instead.  Let `with-suppressed-warnings` control it
    under `lexical`.
---
 lisp/emacs-lisp/bytecomp.el | 8 ++++++++
 lisp/emacs-lisp/cconv.el    | 5 -----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el
index 64a57948017..659d698b603 100644
--- a/lisp/emacs-lisp/bytecomp.el
+++ b/lisp/emacs-lisp/bytecomp.el
@@ -3082,6 +3082,14 @@ If FORM is a lambda or a macro, byte-compile it as a 
function."
               (byte-compile-warn-x
                 arg "repeated variable %s in lambda-list" arg))
              (t
+              (when (and lexical-binding
+                         (cconv--not-lexical-var-p
+                          arg byte-compile-bound-variables)
+                         (byte-compile-warning-enabled-p 'lexical arg))
+                (byte-compile-warn-x
+                 arg
+                 "Lexical argument shadows the dynamic variable %S"
+                 arg))
               (push arg vars))))
       (setq list (cdr list)))))
 
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index 601e2c13d61..3e75020a013 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -682,11 +682,6 @@ FORM is the parent form that binds this var."
     (when lexical-binding
       (dolist (arg args)
         (cond
-         ((cconv--not-lexical-var-p arg cconv--dynbound-variables)
-          (byte-compile-warn-x
-           arg
-           "Lexical argument shadows the dynamic variable %S"
-           arg))
          ((eq ?& (aref (symbol-name arg) 0)) nil) ;Ignore &rest, &optional, ...
          (t (let ((varstruct (list arg nil nil nil nil)))
               (cl-pushnew arg byte-compile-lexical-variables)



reply via email to

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