* lisp/emacs-lisp/cconv.el: Improve line-nb info of unused var warnings
Instead of warning about unused vars during the analysis phase of closure conversion, do it in the actual closure conversion by annotating the code with "unused" warnings, so that the warnings get emitted later by the bytecomp phase, like all other warnings, at which point the line-number info is a bit less imprecise. Take advantage of this change to wrap the expressions of unused let-bound vars inside (ignore ...) so the byte-compiler can better optimize them away. Finally, promote `macroexp--warn-and-return` to "official" status by removing its "--" marker. (cconv-captured+mutated, cconv-lambda-candidates): Remove vars. (cconv-var-classification): New var to replace them. (cconv-warnings-only): Delete function. (cconv--warn-unused-msg, cconv--var-classification): New functions. (cconv--convert-funcbody): Add warnings for unused args. (cconv-convert): Add warnings for unused vars in `let` and `condition-case`. (cconv--analyze-use): Don't emit an "unused var" warning any more, but instead remember the fact in `cconv-var-classification`. * lisp/emacs-lisp/bytecomp.el (byte-compile-force-lexical-warnings): Remove variable. (byte-compile-preprocess): Remove corresponding case. * lisp/emacs-lisp/pcase.el (pcase--if): Don't throw away `test` effects. (\`): * lisp/emacs-lisp/cl-macs.el (cl--do-arglist): Use `car-safe` instead of `car`, so it can more easily be removed by the optimizer if the result is not used. * lisp/emacs-lisp/macroexp.el (macroexp--warn-wrap): New function. (macroexp-warn-and-return): Rename from `macroexp--warn-and-return`.
This commit is contained in:
parent
99340ad17a
commit
a350ae058c
13 changed files with 172 additions and 136 deletions
|
@ -469,8 +469,10 @@ for the result of evaluating EXP (first arg to `pcase').
|
|||
;; the depth of the generated tree.
|
||||
(defun pcase--if (test then else)
|
||||
(cond
|
||||
((eq else :pcase--dontcare) then)
|
||||
((eq then :pcase--dontcare) (debug) else) ;Can/should this ever happen?
|
||||
((eq else :pcase--dontcare) `(progn (ignore ,test) ,then))
|
||||
;; This happens very rarely. Known case:
|
||||
;; (pcase EXP ((and 1 pcase--dontcare) FOO))
|
||||
((eq then :pcase--dontcare) `(progn (ignore ,test) ,else))
|
||||
(t (macroexp-if test then else))))
|
||||
|
||||
;; Note about MATCH:
|
||||
|
@ -845,7 +847,7 @@ Otherwise, it defers to REST which is a list of branches of the form
|
|||
((memq upat '(t _))
|
||||
(let ((code (pcase--u1 matches code vars rest)))
|
||||
(if (eq upat '_) code
|
||||
(macroexp--warn-and-return
|
||||
(macroexp-warn-and-return
|
||||
"Pattern t is deprecated. Use `_' instead"
|
||||
code))))
|
||||
((eq upat 'pcase--dontcare) :pcase--dontcare)
|
||||
|
@ -971,8 +973,8 @@ The predicate is the logical-AND of:
|
|||
(nreverse upats))))
|
||||
((consp qpat)
|
||||
`(and (pred consp)
|
||||
(app car ,(list '\` (car qpat)))
|
||||
(app cdr ,(list '\` (cdr qpat)))))
|
||||
(app car-safe ,(list '\` (car qpat)))
|
||||
(app cdr-safe ,(list '\` (cdr qpat)))))
|
||||
((or (stringp qpat) (numberp qpat) (symbolp qpat)) `',qpat)
|
||||
;; In all other cases just raise an error so we can't break
|
||||
;; backward compatibility when adding \` support for other
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue