[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: byte-compile-maybe-guarded
From: |
Stefan Monnier |
Subject: |
Re: byte-compile-maybe-guarded |
Date: |
Sun, 02 Mar 2008 17:38:23 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) |
> FYI I've restored the code in byte-compile-maybe-guarded that you
> commented out 2007-11-10. Without this code, a false warning is
> produced in the following case:
> foo.el:
> (defsubst foo ()
> (if (featurep 'xemacs) (setq foo t))) ; foo is a free variable
> (provide 'foo)
> bar.el:
> (require 'foo)
> (foo)
It seems the problem is in the (lack of) optimization of forms like
((lambda (args) body) exps)
You can see it by byte-compiling
(defun foo ()
((lambda () (if (featurep 'xemacs) (setq foo t)))))
I.e. the patch below seems to fix the problem the right way.
I'm just not 100% sure it can't introduce an infinite optimization loop.
Stefan
--- orig/lisp/emacs-lisp/byte-opt.el
+++ mod/lisp/emacs-lisp/byte-opt.el
@@ -383,7 +383,9 @@
form))
((or (byte-code-function-p fn)
(eq 'lambda (car-safe fn)))
- (byte-compile-unfold-lambda form))
+ (byte-optimize-form
+ (byte-compile-unfold-lambda form)
+ for-effect))
((memq fn '(let let*))
;; recursively enter the optimizer for the bindings and body
;; of a let or let*. This for depth-firstness: forms that