From 8525be6d5eca0c75008ec1dc799cae537156feea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Wed, 29 Nov 2023 17:51:46 +0100 Subject: [PATCH] Move malformed-function warning from byte-opt to cconv (bug#67483) We shouldn't be warning inside the optimiser in the first place. * lisp/emacs-lisp/byte-opt.el (byte-optimize-form): Remove byte-compile-form-stack manipulation. (byte-optimize-form-code-walker): Move malformed function warning from here... * lisp/emacs-lisp/cconv.el: ...to here. --- lisp/emacs-lisp/byte-opt.el | 6 ------ lisp/emacs-lisp/cconv.el | 14 +++++++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lisp/emacs-lisp/byte-opt.el b/lisp/emacs-lisp/byte-opt.el index 06257a9a2da..7a61a8fce7e 100644 --- a/lisp/emacs-lisp/byte-opt.el +++ b/lisp/emacs-lisp/byte-opt.el @@ -485,10 +485,6 @@ There can be multiple entries for the same NAME if it has several aliases.") (`(,(pred byte-code-function-p) . ,exps) (cons fn (mapcar #'byte-optimize-form exps))) - (`(,(pred (not symbolp)) . ,_) - (byte-compile-warn-x form "`%s' is a malformed function" fn) - form) - ((guard (when for-effect (if-let ((tmp (byte-opt--fget fn 'side-effect-free))) (or byte-compile-delete-errors @@ -514,7 +510,6 @@ There can be multiple entries for the same NAME if it has several aliases.") (byte-optimize-form form for-effect))) (defun byte-optimize-form (form &optional for-effect) - (push form byte-compile-form-stack) (while (progn ;; First, optimize all sub-forms of this one. @@ -531,7 +526,6 @@ There can be multiple entries for the same NAME if it has several aliases.") (byte-compile-log " %s\t==>\t%s" old new) (setq form new) (not (eq new old)))))))) - (pop byte-compile-form-stack) form) (defun byte-optimize--rename-var-body (var new-var body) diff --git a/lisp/emacs-lisp/cconv.el b/lisp/emacs-lisp/cconv.el index 3e75020a013..e65c39e3998 100644 --- a/lisp/emacs-lisp/cconv.el +++ b/lisp/emacs-lisp/cconv.el @@ -615,11 +615,15 @@ places where they originally did not directly appear." (cconv-convert exp env extend)) (`(,func . ,forms) - ;; First element is function or whatever function-like forms are: or, and, - ;; if, catch, progn, prog1, while, until - `(,func . ,(mapcar (lambda (form) - (cconv-convert form env extend)) - forms))) + (if (symbolp func) + ;; First element is function or whatever function-like forms are: + ;; or, and, if, catch, progn, prog1, while, until + `(,func . ,(mapcar (lambda (form) + (cconv-convert form env extend)) + forms)) + (macroexp--warn-wrap form (format-message "Malformed function `%S'" + (car form)) + nil nil))) (_ (or (cdr (assq form env)) form)))) -- 2.39.2