* bug#12532: 24.2.50; wrong results using byte-compile-file with lexical-binding
@ 2012-09-28 11:36 Sergey Vinokurov
2012-09-28 20:22 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Sergey Vinokurov @ 2012-09-28 11:36 UTC (permalink / raw)
To: 12532
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#12532: 24.2.50; wrong results using byte-compile-file with lexical-binding
2012-09-28 11:36 bug#12532: 24.2.50; wrong results using byte-compile-file with lexical-binding Sergey Vinokurov
@ 2012-09-28 20:22 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2012-09-28 20:22 UTC (permalink / raw)
To: Sergey Vinokurov; +Cc: 12532
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-09-28 20:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-28 11:36 bug#12532: 24.2.50; wrong results using byte-compile-file with lexical-binding Sergey Vinokurov
2012-09-28 20:22 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).