GNU bug report logs - #8140
byte-compiler to not warn about conditional defuns that are always defined

Previous Next

Package: emacs;

Reported by: sds <at> gnu.org

Date: Mon, 28 Feb 2011 15:17:01 UTC

Severity: wishlist

Merged with 20144

Found in versions 24.0.50, 25.0.50

To reply to this bug, email your comments to 8140 AT debbugs.gnu.org.

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

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


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8140; Package emacs. (Mon, 28 Feb 2011 15:17:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to sds <at> gnu.org:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 28 Feb 2011 15:17:02 GMT) Full text and rfc822 format available.

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

From: Sam Steingold <sds <at> gnu.org>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.0.50; wrong compilation warning
Date: Mon, 28 Feb 2011 10:16:30 -0500
In GNU Emacs 24.0.50.6 (x86_64-unknown-linux-gnu, X toolkit)
 of 2011-02-28 on tbox
Windowing system distributor `Colin Harrison', version 11.0.60900031
configured using `configure  '--exec-prefix=/opt/emacs/lucid' '--prefix=/opt/emacs' '--with-x-toolkit=lucid''

the following code:

(if (eval-when-compile (eq 'w32 window-system))
    (defun foo () ...) ; woe32 definition
    (defun foo () ...)) ; unix definition

(defun bar () ... (foo) ... )

results in this byte-compilation warning:

In end of data:
lib.el:2029:1:Warning: the function `foo' is not known to be defined.

I think the warning is wrong because it should be pretty easy for the
compiler to see that `foo' is always defined.

-- 
Sam Steingold (http://sds.podval.org/) on CentOS release 5.3 (Final) X
http://dhimmi.com http://truepeace.org http://www.PetitionOnline.com/tap12009/
http://mideasttruth.com http://ffii.org http://www.memritv.org
Even Windows doesn't suck, when you use Common Lisp




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#8140; Package emacs. (Mon, 28 Feb 2011 16:25:01 GMT) Full text and rfc822 format available.

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

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: 8140 <at> debbugs.gnu.org
Subject: Re: bug#8140: 24.0.50; wrong compilation warning
Date: Mon, 28 Feb 2011 11:24:27 -0500
severity 8140 wishlist
thanks

> the following code:

> (if (eval-when-compile (eq 'w32 window-system))
>     (defun foo () ...) ; woe32 definition
>     (defun foo () ...)) ; unix definition

> (defun bar () ... (foo) ... )

> results in this byte-compilation warning:

> In end of data:
> lib.el:2029:1:Warning: the function `foo' is not known to be defined.

> I think the warning is wrong because it should be pretty easy for the
> compiler to see that `foo' is always defined.

That's right.  It's fairly easy to write a code that can decide which
functions are known to exist and which aren't.  OTOH given the existing
bytecomp.el structure, it's not that easy to make it understand that in
the above code `foo' will always be defined.  Of course, maybe there's
a clever way to do it, but at least for now it seems unlikely to happen.

So until it does happen I recommend you use

  (defalias 'foo
    (if blabla
        (lambda () ...)
      (lambda () ...)))

which makes it more obvious to the byte-compiler that `foo' will indeed
always be defined.  The above form works well for single-function
definitions, but it's not as nice when doing

   (cond
    (toto
     (defun foo1 ...)
     (defun foo2 ...)
     (defun foo3 ...))
    (t
     (defun foo1 ...)
     (defun foo2 ...)
     (defun foo3 ...)))

so it would indeed be good to teach the byte-compiler how to figure
these things out.


        Stefan




Severity set to 'wishlist' from 'normal' Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> debbugs.gnu.org. (Mon, 28 Feb 2011 16:25:02 GMT) Full text and rfc822 format available.

Changed bug title to 'byte-compiler to not warn about conditional defuns that are always defined' from '24.0.50; wrong compilation warning' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Fri, 07 Oct 2011 02:00:02 GMT) Full text and rfc822 format available.

Merged 8140 20144. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Thu, 19 Mar 2015 17:55:03 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 47 days ago.

Previous Next


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