From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: esup byte compile warnings Date: Wed, 29 Jan 2020 09:32:18 -0500 Message-ID: References: <15aa1d01-dcff-34c0-0232-141edf1b3739@protonmail.ch> <104542A5-436D-44DB-AEE2-9DB5D64FAC01@protonmail.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="1163"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: GNU Emacs Developers To: Serghei Iakovlev Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Jan 29 15:33:03 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iwoOt-0000GG-EV for ged-emacs-devel@m.gmane-mx.org; Wed, 29 Jan 2020 15:33:03 +0100 Original-Received: from localhost ([::1]:47374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwoOs-0007w3-Gb for ged-emacs-devel@m.gmane-mx.org; Wed, 29 Jan 2020 09:33:02 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52296) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iwoON-0007W1-Am for emacs-devel@gnu.org; Wed, 29 Jan 2020 09:32:32 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iwoOL-0007e3-Fe for emacs-devel@gnu.org; Wed, 29 Jan 2020 09:32:30 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:47185) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iwoOL-0007cs-8x for emacs-devel@gnu.org; Wed, 29 Jan 2020 09:32:29 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 1529A100F88; Wed, 29 Jan 2020 09:32:28 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 38FED100EC5; Wed, 29 Jan 2020 09:32:26 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1580308346; bh=l7Hy1+1kdMBAGci5eID7G2fhr1C4QGyK0XXrn28xff0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=W3RqkNV0C0N6T71SIrgdXTo0AhUYZzvIT+8kvcxNYtLeQlrDMSs5vgqpbfuPFtaPW 50byUGEDpQr0Kl8BvLQBHhwDFp88D4ZXgEOzXVYi5NtxVd7HS1YzLLfE4JUmlwPGIA hsATCS4Xzw6iFqHsrJPagjwpErqhuJPfrb90KX3H06/MFdoMbvEubMu022JsvQaInI HnrKI2CUZMWSOpthGDNEShdj9VfmOmKkiTV4MgbCfbWH0D2S+1piq1zCwH4faFpCoN xPya+CkNgmI1MVhPK2KwxS9cHIGihgROO2kA6DWU2+3kp0oovKxDRH71tBod3Epsfz Hem3DLh/JBlzg== Original-Received: from pastel (unknown [45.72.213.248]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 03FF3120325; Wed, 29 Jan 2020 09:32:25 -0500 (EST) In-Reply-To: <104542A5-436D-44DB-AEE2-9DB5D64FAC01@protonmail.ch> (Serghei Iakovlev's message of "Wed, 29 Jan 2020 12:56:40 +0000") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 132.204.25.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:244749 Archived-At: > Consider the following defun: > > (defun esup-total-exec-time (results) > "Calculate the total execution time of RESULTS." > (cl-loop for result in results > sum (slot-value result 'exec-time) into total-exec-time > finally return total-exec-time)) > > This produces a waring: > > In esup-total-exec-time: > esup.el:166:52: Warning: Unknown slot =E2=80=98exec-time=E2=80=99 This warning means that the bytecompiler has not seen any `defclass` that defines a slot `exec-time`. Maybe it's perfectly normal (you know that the object will indeed have an `exec-time` slot when that code will be executed), e.g. because the object will be created in another file which is not `require`d in this file, but without knowing more about this slot it's hard to tell what's the best way to address the warning. [...looking at https://github.com/jschaf/esup...] Oh, I think it's because of (let ((load-path (append load-path (list esup-load-path)))) (require 'esup-child)) which means that the `require` won't be executed by the byte-compiler (because it's within a `let`). Either you should just drop this `load-path` trickery (and push the responsability of `load-path` manipulation to the code that byte-compiles the files, as usual), or you may want to wrap this within an `eval-and-compile`. > Looks like the reason is that the byte-compiler unable to match > =E2=80=98result=E2=80=99 with the class declaration. The compiler doesn't even try to infer types. It only checks that some class somewhere has defined a slot of that name (that's good enough to catch most typos). Stefan PS: While I'm here I noticed: (eval-when-compile (if (and (<=3D emacs-major-version 24) (<=3D emacs-minor-version 3)) (require 'cl) (require 'cl-lib))) which makes no sense: those two libraries provide the same *kind* of functionality, but under completely different names. The rest of the code uses things like `cl-loop`, so you need to (require 'cl-lib) because that's what the code uses. In Emacs<24.4, `cl-lib` will itself load `cl` (because it uses it internally, but that's an implementation detail).