GNU bug report logs - #18971
25.0.50; incorrect warning from byte compiler

Previous Next

Package: emacs;

Reported by: Tom Tromey <tom <at> tromey.com>

Date: Thu, 6 Nov 2014 04:16:02 UTC

Severity: minor

Tags: wontfix

Found in version 25.0.50

Done: Lars Ingebrigtsen <larsi <at> gnus.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 18971 in the body.
You can then email your comments to 18971 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18971; Package emacs. (Thu, 06 Nov 2014 04:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tom Tromey <tom <at> tromey.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Thu, 06 Nov 2014 04:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tom Tromey <tom <at> tromey.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 25.0.50; incorrect warning from byte compiler
Date: Wed, 05 Nov 2014 21:14:27 -0700
Byte compile this file:

; -*- lexical-binding:t -*-
(require 'bytecomp)
(defun z ()
  (byte-compile-close-variables
   (message "hi")))

I get:

In toplevel form:
q.el:3:1:Warning: Unused lexical variable `byte-compile-free-assignments'
q.el:3:1:Warning: Unused lexical variable `byte-compile-free-references'
q.el:3:1:Warning: Unused lexical variable `byte-compile--outbuffer'

I think the warning seems wrong.  bytecomp.el has a defvar for each of
these variables, so I expected them not to be considered lexical.




In GNU Emacs 25.0.50.8 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.9)
 of 2014-11-05 on bapiya
Repository revision: 118301 monnier <at> iro.umontreal.ca-20141106032723-sooywb316jlfcpd9
Windowing system distributor `Fedora Project', version 11.0.11404000
Configured using:
 `configure --prefix=/home/tromey/Emacs/install'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GCONF GSETTINGS
NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB

Important settings:
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: @im=none
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  shell-dirtrack-mode: t
  diff-auto-refine-mode: t
  flyspell-mode: t
  which-function-mode: t
  global-auto-revert-mode: t
  desktop-save-mode: t
  erc-services-mode: t
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  savehist-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: do-auto-fill

Recent messages:
C-x C-g is undefined
Saving file /home/tromey/Emacs/ET/q.el...
Wrote /home/tromey/Emacs/ET/q.el
Saving file /home/tromey/Emacs/ET/q.el...
Wrote /home/tromey/Emacs/ET/q.el
Making completion list...
Mark saved where search started [2 times]
Mark set
Mark saved where search started
Mark set [2 times]
Quit

Load-path shadows:
/home/tromey/.emacs.d/elpa/css-mode-1.0/css-mode hides /home/tromey/Emacs/install/share/emacs/25.0.50/lisp/textmodes/css-mode
/home/tromey/.emacs.d/elpa/bubbles-0.5/bubbles hides /home/tromey/Emacs/install/share/emacs/25.0.50/lisp/play/bubbles

Features:
(shadow sort mail-extr warnings emacsbug sendmail copyright dabbrev
misearch multi-isearch shell message dired rfc822 mml mml-sec mm-decode
mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums
mailabbrev mail-utils gmm-utils mailheader make-mode texinfo sh-script
smie executable sgml-mode smerge-mode bug-reference goto-addr add-log
cc-mode cc-fonts cc-guess cc-menus cc-cmds vc-arch vc-mtn vc-hg vc-sccs
vc-svn vc-cvs vc-rcs jka-compr vc-bzr vc-git diff-mode easy-mmode
flyspell ispell diminish projectile edmacro kmacro pkg-info find-func
lisp-mnt epl grep compile dash s appt diary-lib diary-loaddefs cal-menu
calendar cal-loaddefs which-func imenu minimap autorevert filenotify
desktop frameset cus-start cus-load status erc-services erc-list
erc-menu erc-join erc-ring erc-networks erc-pcomplete pcomplete
erc-track erc-match erc-button wid-edit erc-fill erc-stamp erc-netsplit
erc-goodies erc erc-backend erc-compat format-spec auth-source cl-macs
gv eieio byte-opt bytecomp byte-compile cl-extra cconv eieio-core
gnus-util mm-util mail-prsvr password-cache thingatpt pp advice help-fns
vc-dir ewoc vc cl-loaddefs cl-lib vc-dispatcher cc-styles cc-align
cc-engine cc-vars cc-defs bbdb timezone ange-ftp comint ansi-color ring
server savehist dwarf-mode-autoloads gdb-shell-autoloads
jabber-autoloads lisppaste-autoloads pydoc-info-autoloads info-look info
easymenu weblogger-autoloads package epg-config bbdb-autoloads time-date
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe
tabulated-list newcomment elisp-mode lisp-mode prog-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer nadvice
loaddefs button faces cus-face macroexp files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process dbusbind
gfilenotify dynamic-setting system-font-setting font-render-setting
move-toolbar gtk x-toolkit x multi-tty emacs)

Memory information:
((conses 16 421995 36333)
 (symbols 48 36948 0)
 (miscs 40 21361 845)
 (strings 32 76233 10784)
 (string-bytes 1 2288448)
 (vectors 16 30564)
 (vector-slots 8 656796 18204)
 (floats 8 151 435)
 (intervals 56 16761 235)
 (buffers 976 171)
 (heap 1024 59018 1707))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18971; Package emacs. (Thu, 06 Nov 2014 15:30:03 GMT) Full text and rfc822 format available.

Message #8 received at 18971 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Tom Tromey <tom <at> tromey.com>
Cc: 18971 <at> debbugs.gnu.org
Subject: Re: bug#18971: 25.0.50; incorrect warning from byte compiler
Date: Thu, 06 Nov 2014 10:29:54 -0500
> ; -*- lexical-binding:t -*-
> (require 'bytecomp)
> (defun z ()
>   (byte-compile-close-variables
>    (message "hi")))

If it hurts, don't do that.

`byte-compile-close-variables' is an internal macro in bytecomp.el.
Why do you need to use it elsewhere?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18971; Package emacs. (Thu, 06 Nov 2014 15:47:02 GMT) Full text and rfc822 format available.

Message #11 received at 18971 <at> debbugs.gnu.org (full text, mbox):

From: Tom Tromey <tom <at> tromey.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 18971 <at> debbugs.gnu.org, Tom Tromey <tom <at> tromey.com>
Subject: Re: bug#18971: 25.0.50; incorrect warning from byte compiler
Date: Thu, 06 Nov 2014 08:46:40 -0700
>>>>> "Stefan" == Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> ; -*- lexical-binding:t -*-
>> (require 'bytecomp)
>> (defun z ()
>> (byte-compile-close-variables
>> (message "hi")))

Stefan> If it hurts, don't do that.

Stefan> `byte-compile-close-variables' is an internal macro in bytecomp.el.
Stefan> Why do you need to use it elsewhere?

I want to be able to call byte-optimize-form and was under the
impression that byte-compile-close-variables was needed.  I'm doing this
for a project I'm working on where it is convenient to let the byte
compiler code macroexpand a form and do some simple optimizations on it.

I guess I don't understand why this would not be a bug, though.
Or at least it perplexes me why this happens; my only theory is that
somehow the defvars aren't seen when byte-compiling my file.  I suppose
if I wanted to export a macro like this, I would need it to come with
special declarations for the variables?  Except I didn't see a way to do
that either.

Tom




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18971; Package emacs. (Thu, 06 Nov 2014 23:28:02 GMT) Full text and rfc822 format available.

Message #14 received at 18971 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: Tom Tromey <tom <at> tromey.com>
Cc: 18971 <at> debbugs.gnu.org
Subject: Re: bug#18971: 25.0.50; incorrect warning from byte compiler
Date: Thu, 06 Nov 2014 18:27:10 -0500
> I want to be able to call byte-optimize-form and was under the
> impression that byte-compile-close-variables was needed.  I'm doing this
> for a project I'm working on where it is convenient to let the byte
> compiler code macroexpand a form and do some simple optimizations on it.

Just curious: why do you need those simple optimizations performed by
byte-optimize-form?

> I guess I don't understand why this would not be a bug, though.
> Or at least it perplexes me why this happens; my only theory is that
> somehow the defvars aren't seen when byte-compiling my file.  I suppose
> if I wanted to export a macro like this, I would need it to come with
> special declarations for the variables?  Except I didn't see a way to do
> that either.

Those vars are not globally bound, i.e. they are only declared with
(defvar <var>) and this only affects the file in which they appear (or
even the scope, in case they appear within a defun body).

So the macro would need to expand to something like

   (progn
     (defvar byte-compile-free-assignments)
     ...
     (defvar byte-compile-free-references)
     (let (...) ...))

if it was meant to be used outside of bytecomp.el.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18971; Package emacs. (Mon, 29 Dec 2014 19:41:03 GMT) Full text and rfc822 format available.

Message #17 received at 18971 <at> debbugs.gnu.org (full text, mbox):

From: Tom Tromey <tom <at> tromey.com>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 18971 <at> debbugs.gnu.org, Tom Tromey <tom <at> tromey.com>
Subject: Re: bug#18971: 25.0.50; incorrect warning from byte compiler
Date: Mon, 29 Dec 2014 12:40:35 -0700
>> I want to be able to call byte-optimize-form and was under the
>> impression that byte-compile-close-variables was needed.  I'm doing this
>> for a project I'm working on where it is convenient to let the byte
>> compiler code macroexpand a form and do some simple optimizations on it.

Stefan> Just curious: why do you need those simple optimizations performed by
Stefan> byte-optimize-form?

I'm writing an elisp compiler and it just seemed handy.
I can probably reimplement the optimizations though.

Tom




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18971; Package emacs. (Tue, 30 Dec 2014 02:49:01 GMT) Full text and rfc822 format available.

Message #20 received at 18971 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Tom Tromey <tom <at> tromey.com>
Cc: 18971 <at> debbugs.gnu.org
Subject: Re: bug#18971: 25.0.50; incorrect warning from byte compiler
Date: Mon, 29 Dec 2014 21:48:44 -0500
> I'm writing an elisp compiler and it just seemed handy.
> I can probably reimplement the optimizations though.

Or you can add all the corresponding (defvar <foo>), of course.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18971; Package emacs. (Wed, 12 Jun 2019 15:12:02 GMT) Full text and rfc822 format available.

Message #23 received at 18971 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 18971 <at> debbugs.gnu.org, Tom Tromey <tom <at> tromey.com>
Subject: Re: bug#18971: 25.0.50; incorrect warning from byte compiler
Date: Wed, 12 Jun 2019 17:11:06 +0200
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> I'm writing an elisp compiler and it just seemed handy.
>> I can probably reimplement the optimizations though.
>
> Or you can add all the corresponding (defvar <foo>), of course.

So there doesn't seem to be a bug here, and I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 12 Jun 2019 15:12:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 18971 <at> debbugs.gnu.org and Tom Tromey <tom <at> tromey.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 12 Jun 2019 15:12:02 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. (Thu, 11 Jul 2019 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 285 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.