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`.
This commit is contained in:
parent
e85ebb3d82
commit
0228421e34
2 changed files with 8 additions and 5 deletions
|
@ -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)))))
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue