unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* strange byte compiler behavior
@ 2007-12-31 20:55 Dan Nicolaescu
  2007-12-31 21:37 ` martin rudalics
  2008-01-02 19:48 ` Dan Nicolaescu
  0 siblings, 2 replies; 17+ messages in thread
From: Dan Nicolaescu @ 2007-12-31 20:55 UTC (permalink / raw)
  To: emacs-devel


When compiling vc-cvs in batch mode (cd emacs/lisp; make recompile) 
no warning is issued. 

When compiling it with M-x byte-compile-file this warning is issued:

In vc-cvs-register:
vc-cvs.el:301:41:Warning: reference to free variable `file'


The warning is correct, it looks like vc-cvs-register has a bug, it
should look at `files', not `file'.

Any idea why this warning is not issued in batch mode?

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2007-12-31 20:55 strange byte compiler behavior Dan Nicolaescu
@ 2007-12-31 21:37 ` martin rudalics
  2007-12-31 22:11   ` Dan Nicolaescu
  2008-01-02 19:48 ` Dan Nicolaescu
  1 sibling, 1 reply; 17+ messages in thread
From: martin rudalics @ 2007-12-31 21:37 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

There's still the occurrence of `file' in `vc-next-action' I reported in

http://lists.gnu.org/archive/html/emacs-devel/2007-12/msg00872.html

      ((stringp state)
       (let ((revision
	     (if verbose
		 (read-string "Revision to steal: ")
	       (vc-working-revision file))))
	                            ^^^^
	(dolist (file files) (vc-steal-lock file revision state))))

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2007-12-31 21:37 ` martin rudalics
@ 2007-12-31 22:11   ` Dan Nicolaescu
  2007-12-31 22:30     ` martin rudalics
  0 siblings, 1 reply; 17+ messages in thread
From: Dan Nicolaescu @ 2007-12-31 22:11 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

martin rudalics <rudalics@gmx.at> writes:

  > There's still the occurrence of `file' in `vc-next-action' I reported in
  > 
  > http://lists.gnu.org/archive/html/emacs-devel/2007-12/msg00872.html
  > 
  >      ((stringp state)
  >       (let ((revision
  > 	     (if verbose
  > 		 (read-string "Revision to steal: ")
  > 	       (vc-working-revision file))))
  > 	                            ^^^^
  > 	(dolist (file files) (vc-steal-lock file revision state))))

Interesting. No warning is ever issued for this one, and an incorrect
one is issued for another occurrence of `file' in that file in
interactive mode.

[I think is better to refrain from fixing the code until the byte
compiler issues are analyzed].

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2007-12-31 22:11   ` Dan Nicolaescu
@ 2007-12-31 22:30     ` martin rudalics
  2007-12-31 22:42       ` Dan Nicolaescu
  0 siblings, 1 reply; 17+ messages in thread
From: martin rudalics @ 2007-12-31 22:30 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

> Interesting. No warning is ever issued for this one, and an incorrect
> one is issued for another occurrence of `file' in that file in
> interactive mode.

IIRC, it's a known issue with the byte-compiler.  The "incorrect"
warning you see is the warning for the one I mention.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2007-12-31 22:30     ` martin rudalics
@ 2007-12-31 22:42       ` Dan Nicolaescu
  2008-01-01 10:33         ` martin rudalics
  0 siblings, 1 reply; 17+ messages in thread
From: Dan Nicolaescu @ 2007-12-31 22:42 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

martin rudalics <rudalics@gmx.at> writes:

  > > Interesting. No warning is ever issued for this one, and an incorrect
  > > one is issued for another occurrence of `file' in that file in
  > > interactive mode.
  > 
  > IIRC, it's a known issue with the byte-compiler.  The "incorrect"
  > warning you see is the warning for the one I mention.

Doubtful, I fixed that issue in my tree and I still get a warning.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2007-12-31 22:42       ` Dan Nicolaescu
@ 2008-01-01 10:33         ` martin rudalics
  0 siblings, 0 replies; 17+ messages in thread
From: martin rudalics @ 2008-01-01 10:33 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

 >   > IIRC, it's a known issue with the byte-compiler.  The "incorrect"
 >   > warning you see is the warning for the one I mention.
 >
 > Doubtful, I fixed that issue in my tree and I still get a warning.

Because there's yet another one here:

	      (setq revision (read-string "New revision or backend: "))
	      (let ((vsym (intern (upcase revision))))
		(if (member vsym vc-handled-backends)
		    (vc-transfer-file file vsym)
		                      ^^^^
		  (vc-checkin ready-for-commit revision))))))))

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2007-12-31 20:55 strange byte compiler behavior Dan Nicolaescu
  2007-12-31 21:37 ` martin rudalics
@ 2008-01-02 19:48 ` Dan Nicolaescu
  2008-01-02 21:49   ` martin rudalics
  2008-01-02 23:17   ` Dan Nicolaescu
  1 sibling, 2 replies; 17+ messages in thread
From: Dan Nicolaescu @ 2008-01-02 19:48 UTC (permalink / raw)
  To: emacs-devel

Dan Nicolaescu <dann@ics.uci.edu> writes:

  > When compiling vc-cvs in batch mode (cd emacs/lisp; make recompile) 
  > no warning is issued. 
  > 
  > When compiling it with M-x byte-compile-file this warning is issued:
  > 
  > In vc-cvs-register:
  > vc-cvs.el:301:41:Warning: reference to free variable `file'
  > 
  > 
  > The warning is correct, it looks like vc-cvs-register has a bug, it
  > should look at `files', not `file'.
  > 
  > Any idea why this warning is not issued in batch mode?


Investigating a bit: 

1. 
cd lisp ; make recompile 

which runs: -batch --no-site-file --multibyte --eval "(batch-byte-recompile-directory 0)"
does NOT warn

but running: 

-batch --no-site-file --multibyte --eval '(byte-compile-file "vc-cvs.el")'

warns

2. the warning is related to the name `file', if the variable is renamed
`file1' both the batch mode and interactive mode produce a warning.

3. Adding this:

   (message "var %s boundp %s" var  (boundp var))
to `byte-compile-variable-ref' shows that `file' is bound for the function
in question.  Which would explain the results. 
Any idea what causes `file' to be bound? (Assuming that boundp is the
correct test in that context...)

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-02 19:48 ` Dan Nicolaescu
@ 2008-01-02 21:49   ` martin rudalics
  2008-01-02 22:13     ` Dan Nicolaescu
  2008-01-02 23:17   ` Dan Nicolaescu
  1 sibling, 1 reply; 17+ messages in thread
From: martin rudalics @ 2008-01-02 21:49 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

 > which runs: -batch --no-site-file --multibyte --eval "(batch-byte-recompile-directory 0)"
 > does NOT warn

What happens when you comment out the disjunct

(memq var byte-compile-free-references)

from `byte-compile-variable-ref'?  Alternatively what is the value of
that variable when you do not get the warning?  Also, could you try the
same with just the file in question in the directory you recompile?

 >    (message "var %s boundp %s" var  (boundp var))
 > to `byte-compile-variable-ref' shows that `file' is bound for the function
 > in question.  Which would explain the results.
 > Any idea what causes `file' to be bound? (Assuming that boundp is the
 > correct test in that context...)

Since `byte-compile-variable-ref' has

	  (or (boundp var)

it would be interesting _where_ in `byte-compile-variable-ref' you
inserted that.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-02 21:49   ` martin rudalics
@ 2008-01-02 22:13     ` Dan Nicolaescu
  0 siblings, 0 replies; 17+ messages in thread
From: Dan Nicolaescu @ 2008-01-02 22:13 UTC (permalink / raw)
  To: martin rudalics; +Cc: emacs-devel

martin rudalics <rudalics@gmx.at> writes:

  > > which runs: -batch --no-site-file --multibyte --eval "(batch-byte-recompile-directory 0)"
  > > does NOT warn
  > 
  > What happens when you comment out the disjunct
  > 
  > (memq var byte-compile-free-references)
  > 
  > from `byte-compile-variable-ref'?  Alternatively what is the value of
  > that variable when you do not get the warning?  

I can't try this right now, but why would it be relevant. 
Because (boundp var) is true, then (or (boundp var) BLAH) is true and
BLAH does not get executed after that. 



  > Also, could you try the same with just the file in question in the
  > directory you recompile?

I tried that before, no difference. 

  > >    (message "var %s boundp %s" var  (boundp var))
  > > to `byte-compile-variable-ref' shows that `file' is bound for the function
  > > in question.  Which would explain the results.
  > > Any idea what causes `file' to be bound? (Assuming that boundp is the
  > > correct test in that context...)
  > 
  > Since `byte-compile-variable-ref' has
  > 
  > 	  (or (boundp var)
  > 
  > it would be interesting _where_ in `byte-compile-variable-ref' you
  > inserted that.

At the beginning of the function, but as I explained above, it is not
relevant.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-02 19:48 ` Dan Nicolaescu
  2008-01-02 21:49   ` martin rudalics
@ 2008-01-02 23:17   ` Dan Nicolaescu
  2008-01-02 23:24     ` David Kastrup
  2008-01-04  5:27     ` Richard Stallman
  1 sibling, 2 replies; 17+ messages in thread
From: Dan Nicolaescu @ 2008-01-02 23:17 UTC (permalink / raw)
  To: emacs-devel

Dan Nicolaescu <dann@ics.uci.edu> writes:

  > Dan Nicolaescu <dann@ics.uci.edu> writes:
  > 
  >   > When compiling vc-cvs in batch mode (cd emacs/lisp; make recompile) 
  >   > no warning is issued. 
  >   > 
  >   > When compiling it with M-x byte-compile-file this warning is issued:
  >   > 
  >   > In vc-cvs-register:
  >   > vc-cvs.el:301:41:Warning: reference to free variable `file'
  >   > 
  >   > 
  >   > The warning is correct, it looks like vc-cvs-register has a bug, it
  >   > should look at `files', not `file'.
  >   > 
  >   > Any idea why this warning is not issued in batch mode?
  > 
  > 
  > Investigating a bit: 
  > 
  > 1. 
  > cd lisp ; make recompile 
  > 
  > which runs: -batch --no-site-file --multibyte --eval "(batch-byte-recompile-directory 0)"
  > does NOT warn
  > 
  > but running: 
  > 
  > -batch --no-site-file --multibyte --eval '(byte-compile-file "vc-cvs.el")'
  > 
  > warns
  > 
  > 2. the warning is related to the name `file', if the variable is renamed
  > `file1' both the batch mode and interactive mode produce a warning.
  > 
  > 3. Adding this:
  > 
  >    (message "var %s boundp %s" var  (boundp var))
  > to `byte-compile-variable-ref' shows that `file' is bound for the function
  > in question.  Which would explain the results. 
  > Any idea what causes `file' to be bound? (Assuming that boundp is the
  > correct test in that context...)

`byte-recompile-directory' contains a form: "(dolist (file files)" that
calls `byte-compile-file'. As a consequence (boundp 'file) to be t when
`byte-compile-file' is called.

What is TRTD here?

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-02 23:17   ` Dan Nicolaescu
@ 2008-01-02 23:24     ` David Kastrup
  2008-01-04  5:27     ` Richard Stallman
  1 sibling, 0 replies; 17+ messages in thread
From: David Kastrup @ 2008-01-02 23:24 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

Dan Nicolaescu <dann@ics.uci.edu> writes:

> Dan Nicolaescu <dann@ics.uci.edu> writes:
>
>   > Investigating a bit: 
>   > 
>   > 1. 
>   > cd lisp ; make recompile 
>   > 
>   > which runs: -batch --no-site-file --multibyte --eval "(batch-byte-recompile-directory 0)"
>   > does NOT warn
>
> `byte-recompile-directory' contains a form: "(dolist (file files)" that
> calls `byte-compile-file'. As a consequence (boundp 'file) to be t when
> `byte-compile-file' is called.
>
> What is TRTD here?

Lexical scope.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-02 23:17   ` Dan Nicolaescu
  2008-01-02 23:24     ` David Kastrup
@ 2008-01-04  5:27     ` Richard Stallman
  2008-01-04  6:10       ` Stefan Monnier
  1 sibling, 1 reply; 17+ messages in thread
From: Richard Stallman @ 2008-01-04  5:27 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

    `byte-recompile-directory' contains a form: "(dolist (file files)" that
    calls `byte-compile-file'. As a consequence (boundp 'file) to be t when
    `byte-compile-file' is called.

That's a joke on us.

The easy solution is to rename the variables in `byte-recompile-directory'
and maybe a few other relevant functions.

A deeper solution would be to get rid of the boundp test.

I'm sure it was added for a reason -- there must have been lots of
spurious warnings without that boundp test.  But nowadays we have done
a lot to eliminate such warnings with defvars.  Perhaps now if we get
rid of that boundp test the results would be ok.

Does someone want to try it?

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-04  5:27     ` Richard Stallman
@ 2008-01-04  6:10       ` Stefan Monnier
  2008-01-05 14:29         ` Richard Stallman
  0 siblings, 1 reply; 17+ messages in thread
From: Stefan Monnier @ 2008-01-04  6:10 UTC (permalink / raw)
  To: rms; +Cc: Dan Nicolaescu, emacs-devel

> A deeper solution would be to get rid of the boundp test.

> I'm sure it was added for a reason -- there must have been lots of
> spurious warnings without that boundp test.  But nowadays we have done
> a lot to eliminate such warnings with defvars.  Perhaps now if we get
> rid of that boundp test the results would be ok.

> Does someone want to try it?

No need to try: the boundp test is still needed to catch the case of
a variable defined globally in all cases (e.g. in C code or in preloaded
packages) as well as for variables defined in packages that are
`require'd (or loaded transitively by some of the `require'd packages).


        Stefan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-04  6:10       ` Stefan Monnier
@ 2008-01-05 14:29         ` Richard Stallman
  2008-01-06  2:00           ` Stefan Monnier
  0 siblings, 1 reply; 17+ messages in thread
From: Richard Stallman @ 2008-01-05 14:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: dann, emacs-devel

    No need to try: the boundp test is still needed to catch the case of
    a variable defined globally in all cases (e.g. in C code or in preloaded
    packages) as well as for variables defined in packages that are
    `require'd (or loaded transitively by some of the `require'd packages).

Would you please fill in the gaps in that argument?
I don't see why it is needed for those.  Shouldn't those
variables be defvar'd?

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-05 14:29         ` Richard Stallman
@ 2008-01-06  2:00           ` Stefan Monnier
  2008-01-06 16:34             ` martin rudalics
  2008-01-06 18:09             ` Richard Stallman
  0 siblings, 2 replies; 17+ messages in thread
From: Stefan Monnier @ 2008-01-06  2:00 UTC (permalink / raw)
  To: rms; +Cc: dann, emacs-devel

>     No need to try: the boundp test is still needed to catch the case of
>     a variable defined globally in all cases (e.g. in C code or in preloaded
>     packages) as well as for variables defined in packages that are
>     `require'd (or loaded transitively by some of the `require'd packages).

> Would you please fill in the gaps in that argument?
> I don't see why it is needed for those.  Shouldn't those
> variables be defvar'd?

They are, but elsewhere and the byte-compiler only knows about it via
`boundp': it doesn't keep its own list of defvar'd variables.


        Stefan

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-06  2:00           ` Stefan Monnier
@ 2008-01-06 16:34             ` martin rudalics
  2008-01-06 18:09             ` Richard Stallman
  1 sibling, 0 replies; 17+ messages in thread
From: martin rudalics @ 2008-01-06 16:34 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: dann, rms, emacs-devel

> They are, but elsewhere and the byte-compiler only knows about it via
> `boundp': it doesn't keep its own list of defvar'd variables.

aka `heisenboundp'

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: strange byte compiler behavior
  2008-01-06  2:00           ` Stefan Monnier
  2008-01-06 16:34             ` martin rudalics
@ 2008-01-06 18:09             ` Richard Stallman
  1 sibling, 0 replies; 17+ messages in thread
From: Richard Stallman @ 2008-01-06 18:09 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: dann, emacs-devel

    They are, but elsewhere and the byte-compiler only knows about it via
    `boundp': it doesn't keep its own list of defvar'd variables.

Indeed, that is true.  But we COULD make it check for a variable doc
string instead.

The effect would be that variables defvar'd in another file with no
doc string would get warnings.  Maybe that is not a bad result.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2008-01-06 18:09 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-31 20:55 strange byte compiler behavior Dan Nicolaescu
2007-12-31 21:37 ` martin rudalics
2007-12-31 22:11   ` Dan Nicolaescu
2007-12-31 22:30     ` martin rudalics
2007-12-31 22:42       ` Dan Nicolaescu
2008-01-01 10:33         ` martin rudalics
2008-01-02 19:48 ` Dan Nicolaescu
2008-01-02 21:49   ` martin rudalics
2008-01-02 22:13     ` Dan Nicolaescu
2008-01-02 23:17   ` Dan Nicolaescu
2008-01-02 23:24     ` David Kastrup
2008-01-04  5:27     ` Richard Stallman
2008-01-04  6:10       ` Stefan Monnier
2008-01-05 14:29         ` Richard Stallman
2008-01-06  2:00           ` Stefan Monnier
2008-01-06 16:34             ` martin rudalics
2008-01-06 18:09             ` Richard Stallman

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).