GNU bug report logs -
#12532
24.2.50; wrong results using byte-compile-file with lexical-binding
Previous Next
Reported by: Sergey Vinokurov <serg.foo <at> gmail.com>
Date: Fri, 28 Sep 2012 15:55:01 UTC
Severity: normal
Tags: notabug
Found in version 24.2.50
Done: Glenn Morris <rgm <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
On trunk Emacs compiling function with argument names declared as special
somewhere, like mode-name, resulting function produced by byte-compile-file is
different from function obtained by evaluating definition or byte-compiling
that definition in buffer. This code uses all three possibilities and reports
evaluating results
(progn
(defvar *myvar* 'never-shows-up)
(let ((tmp (make-temp-file "test" nil ".el"))
(form '(defun quux (*myvar*)
(mapcar (lambda (y)
(list *myvar* y))
'(a)))))
(eval form) ;; direct load
(message "plain: %s" (eval '(quux t)))
(eval '(byte-compile #'quux)) ;; byte-compile definition alone
(message "byte-compiled: %s" (eval '(quux t)))
(with-temp-buffer
(insert ";; -*- lexical-binding: t -*-\n")
(princ form (current-buffer))
;; uncomment this and reassure that byte-compile-file is still wrong
;; (insert "\n\n;; Local Variables:\n;; lexical-binding: t\n;; End:")
(write-region (point-min) (point-max) tmp))
(byte-compile-file tmp)
(load-file (byte-compile-dest-file tmp))
(message "file byte-compiled: %s" (eval '(quux t)))
t))
All three outputs should be equal, but result of loaded byte-compiled function
differs
plain: ((t a))
byte-compiled: ((t a))
...
file byte-compiled: ((never-shows-up a))
Also byte-compile-file produced a warning
test12592_hY.el:2:1:Warning: Argument *myvar* is not a lexical variable
but (byte-compile #'quux) hasn't.
Using line with ";; Local Variables:" instead of "-*- lexical-binding: t -*-"
does not solve the problem either. But if lexical-binding is not specified as
a file-local variable it behaves correctly.
This bug report was last modified 12 years and 311 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.