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

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Severity: wishlist; Reported by: sds@HIDDEN; merged with #20144; dated Mon, 28 Feb 2011 15:17:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Merged 8140 20144. Request was from Glenn Morris <rgm@HIDDEN> to control <at> debbugs.gnu.org. Full text 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@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Severity set to 'wishlist' from 'normal' Request was from Stefan Monnier <monnier@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 8140 <at> debbugs.gnu.org:


Received: (at 8140) by debbugs.gnu.org; 28 Feb 2011 16:24:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 28 11:24:39 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Pu5tl-00064r-WB
	for submit <at> debbugs.gnu.org; Mon, 28 Feb 2011 11:24:38 -0500
Received: from ironport2-out.teksavvy.com ([206.248.154.183]
	helo=ironport2-out.pppoe.ca)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>)
	id 1Pu5tk-00064d-6F; Mon, 28 Feb 2011 11:24:36 -0500
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AmwIAGdba01FxKsT/2dsb2JhbACYMo4UdbxShWEEhRCPXw
X-IronPort-AV: E=Sophos;i="4.62,240,1297054800"; d="scan'208";a="93800630"
Received: from 69-196-171-19.dsl.teksavvy.com (HELO ceviche.home)
	([69.196.171.19])
	by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA;
	28 Feb 2011 11:24:27 -0500
Received: by ceviche.home (Postfix, from userid 20848)
	id 3CEAD660D6; Mon, 28 Feb 2011 11:24:27 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: 8140 <at> debbugs.gnu.org
Subject: Re: bug#8140: 24.0.50; wrong compilation warning
Message-ID: <jwvoc5w2kxk.fsf-monnier+emacs@HIDDEN>
References: <svbp1wkx4h.fsf@HIDDEN>
Date: Mon, 28 Feb 2011 11:24:27 -0500
In-Reply-To: <svbp1wkx4h.fsf@HIDDEN> (Sam Steingold's message of "Mon, 
	28 Feb 2011 10:16:30 -0500")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 8140
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.1 (--)

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




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8140; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 28 Feb 2011 15:17:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Feb 28 10:17:01 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Pu4qK-0004a0-NN
	for submit <at> debbugs.gnu.org; Mon, 28 Feb 2011 10:17:01 -0500
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <sam.steingold@HIDDEN>) id 1Pu4qH-0004Zn-Hl
	for submit <at> debbugs.gnu.org; Mon, 28 Feb 2011 10:16:58 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <sam.steingold@HIDDEN>) id 1Pu4qB-0008LD-At
	for submit <at> debbugs.gnu.org; Mon, 28 Feb 2011 10:16:52 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,
	T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([199.232.76.165]:55536)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <sam.steingold@HIDDEN>) id 1Pu4qB-0008L9-8g
	for submit <at> debbugs.gnu.org; Mon, 28 Feb 2011 10:16:51 -0500
Received: from [140.186.70.92] (port=38018 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1Pu4q9-000084-Hx
	for bug-gnu-emacs@HIDDEN; Mon, 28 Feb 2011 10:16:50 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <sam.steingold@HIDDEN>) id 1Pu4q8-0008JU-BK
	for bug-gnu-emacs@HIDDEN; Mon, 28 Feb 2011 10:16:49 -0500
Received: from mail-vw0-f41.google.com ([209.85.212.41]:36253)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <sam.steingold@HIDDEN>)
	id 1Pu4q6-0008IQ-5R; Mon, 28 Feb 2011 10:16:46 -0500
Received: by vws13 with SMTP id 13so4055841vws.0
	for <multiple recipients>; Mon, 28 Feb 2011 07:16:44 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:sender:from:to:subject:user-agent
	:mail-copies-to:return-receipt-to:reply-to:x-attribution
	:x-disclaimer:date:message-id:mime-version:content-type;
	bh=WCByvXIK+68TTcjJmmrPht2pnIzqa/D5wflhz1YOsQA=;
	b=ll8r71BGUZQp1FuEsZUQXhnZM/ezxy7HuUzrhnDEYAYNAS/RPgN6VGdRJXCDK8ZAUD
	NmCLjiFCSx6HcnyMqHM1k34sDwcuvXecRgEvX6ghnvijqWjg6ZN+J5Xj3MXanwn7KurU
	+IqT2V3Y1cj8ELYnXIS4MMX0ZTaFPX0/MIimQ=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=sender:from:to:subject:user-agent:mail-copies-to:return-receipt-to
	:reply-to:x-attribution:x-disclaimer:date:message-id:mime-version
	:content-type;
	b=rr5F3Odub2DWBgB67y41CAddbzFec70zmHxPJz7+CvfEDb3TvSKt7tfNR4SzyOAlZU
	a0LjHi5h0XDKn5IgEt7xsww+XIoNRgGmVY/LXZD9TLM8P58qVqWRaDDgqIZw6aZPQZD/
	Whc7Z7+iQ9isC4RW0rssUA8Wd81VzKACuVyV0=
Received: by 10.52.166.195 with SMTP id zi3mr385618vdb.89.1298906192971;
	Mon, 28 Feb 2011 07:16:32 -0800 (PST)
Received: from tbox.wtc.algo (rrcs-24-103-48-205.nyc.biz.rr.com
	[24.103.48.205])
	by mx.google.com with ESMTPS id c16sm629692vdu.31.2011.02.28.07.16.31
	(version=TLSv1/SSLv3 cipher=OTHER);
	Mon, 28 Feb 2011 07:16:31 -0800 (PST)
From: Sam Steingold <sds@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 24.0.50; wrong compilation warning
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Mail-Copies-To: never
X-Attribution: Sam
X-Disclaimer: You should not expect anyone to agree with me.
Date: Mon, 28 Feb 2011 10:16:30 -0500
Message-ID: <svbp1wkx4h.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 199.232.76.165
X-Spam-Score: -5.5 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
Reply-To: sds@HIDDEN
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.6 (-----)

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




Acknowledgement sent to sds@HIDDEN:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8140; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Thu, 19 Mar 2015 18:00:05 UTC

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