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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12532 in the body.
You can then email your comments to 12532 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#12532
; Package
emacs
.
(Fri, 28 Sep 2012 15:55:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Sergey Vinokurov <serg.foo <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Fri, 28 Sep 2012 15:55:02 GMT)
Full text and
rfc822 format available.
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.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#12532
; Package
emacs
.
(Fri, 28 Sep 2012 20:24:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 12532 <at> debbugs.gnu.org (full text, mbox):
tags 12532 notabug
thanks
> 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
Yes. Using special variables as function arguments is not supported for
lexical-binding code. So the behavior can change according to the phase
of the moon. That's also why the byte-compiler warns you that
test12592_hY.el:2:1:Warning: Argument *myvar* is not a lexical variable
Stefan
Added tag(s) notabug.
Request was from
Stefan Monnier <monnier <at> IRO.UMontreal.CA>
to
control <at> debbugs.gnu.org
.
(Fri, 28 Sep 2012 20:24:02 GMT)
Full text and
rfc822 format available.
bug closed, send any further explanations to
12532 <at> debbugs.gnu.org and Sergey Vinokurov <serg.foo <at> gmail.com>
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Fri, 12 Oct 2012 01:09:01 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Fri, 09 Nov 2012 12:24:03 GMT)
Full text and
rfc822 format available.
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.