summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/cconv.el
diff options
context:
space:
mode:
authorAlan Mackenzie <acm@muc.de>2022-04-22 19:11:31 +0000
committerAlan Mackenzie <acm@muc.de>2022-04-22 19:11:31 +0000
commit0b9b363dabd70032a288e14333896022caa2d252 (patch)
tree851501a770052112a5a88886caa68ea00e9e407b /lisp/emacs-lisp/cconv.el
parent5b23c9942ae057c886e68edb8c4bf09bf7e8eda9 (diff)
downloademacs-0b9b363dabd70032a288e14333896022caa2d252.tar.gz
emacs-0b9b363dabd70032a288e14333896022caa2d252.tar.bz2
emacs-0b9b363dabd70032a288e14333896022caa2d252.zip
Byte compiler: Prevent special forms' symbols being replaced by bare symbols
These are symbols with position from source code, which should not be replaced by bare symbols in, e.g., optimization functions. * lisp/Makefile.in: (BYTE_COMPILE_FLAGS, compile-first case): Set max-specpdl-size to 5000 for the benefit of lisp/emacs-lisp/comp.el. * lisp/emacs-lisp/byte-opt.el (byte-optimize-form-code-walker) (byte-optimize--rename-var, byte-optimize-if, byte-optimize-letX) * lisp/emacs-lisp/bytecomp.el (byte-compile-recurse-toplevel) (byte-compile-lambda) * lisp/emacs-lisp/cconv.el (cconv-convert) * lisp/emacs-lisp/macroexp.el (macroexp--expand-all): Preserve, e.g., (car form) in the byte compiler, when this form's car is a symbol with position of a special form, rather than replacing the symbol with a bare symbol, e.g. 'cond.
Diffstat (limited to 'lisp/emacs-lisp/cconv.el')
-rw-r--r--lisp/emacs-lisp/cconv.el22
1 files changed, 11 insertions, 11 deletions
diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el
index be4fea7be14..4535f1aa6eb 100644
--- a/lisp/emacs-lisp/cconv.el
+++ b/lisp/emacs-lisp/cconv.el
@@ -500,11 +500,11 @@ places where they originally did not directly appear."
args)))
(`(cond . ,cond-forms) ; cond special form
- `(cond . ,(mapcar (lambda (branch)
- (mapcar (lambda (form)
- (cconv-convert form env extend))
- branch))
- cond-forms)))
+ `(,(car form) . ,(mapcar (lambda (branch)
+ (mapcar (lambda (form)
+ (cconv-convert form env extend))
+ branch))
+ cond-forms)))
(`(function (lambda ,args . ,body) . ,_)
(let ((docstring (if (eq :documentation (car-safe (car body)))
@@ -538,7 +538,7 @@ places where they originally did not directly appear."
(msg (when (eq class :unused)
(cconv--warn-unused-msg var "variable")))
(newprotform (cconv-convert protected-form env extend)))
- `(condition-case ,var
+ `(,(car form) ,var
,(if msg
(macroexp--warn-wrap var msg newprotform 'lexical)
newprotform)
@@ -554,9 +554,9 @@ places where they originally did not directly appear."
`((let ((,var (list ,var))) ,@body))))))
handlers))))
- (`(unwind-protect ,form . ,body)
- `(unwind-protect ,(cconv-convert form env extend)
- :fun-body ,(cconv--convert-function () body env form)))
+ (`(unwind-protect ,form1 . ,body)
+ `(,(car form) ,(cconv-convert form1 env extend)
+ :fun-body ,(cconv--convert-function () body env form1)))
(`(setq . ,forms) ; setq special form
(if (= (logand (length forms) 1) 1)
@@ -568,7 +568,7 @@ places where they originally did not directly appear."
(sym-new (or (cdr (assq sym env)) sym))
(value (cconv-convert (pop forms) env extend)))
(push (pcase sym-new
- ((pred symbolp) `(setq ,sym-new ,value))
+ ((pred symbolp) `(,(car form) ,sym-new ,value))
(`(car-safe ,iexp) `(setcar ,iexp ,value))
;; This "should never happen", but for variables which are
;; mutated+captured+unused, we may end up trying to `setq'
@@ -604,7 +604,7 @@ places where they originally did not directly appear."
(cons fun args)))))))
(`(interactive . ,forms)
- `(interactive . ,(mapcar (lambda (form)
+ `(,(car form) . ,(mapcar (lambda (form)
(cconv-convert form nil nil))
forms)))