From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#72313: 31.0.50; Warning about cl-member possibly being undefined when using cl-pushnew Date: Sat, 27 Jul 2024 03:01:32 -0400 Message-ID: References: <874j8bx5gr.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23176"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 72313@debbugs.gnu.org To: Tassilo Horn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jul 27 09:02:16 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1sXbRY-0005u0-41 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 27 Jul 2024 09:02:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sXbRD-0008AJ-F4; Sat, 27 Jul 2024 03:01:55 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sXbRB-0008A3-PA for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2024 03:01:53 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sXbRB-0004N6-Fv for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2024 03:01:53 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sXbRK-00023b-3C for bug-gnu-emacs@gnu.org; Sat, 27 Jul 2024 03:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 27 Jul 2024 07:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72313 X-GNU-PR-Package: emacs Original-Received: via spool by 72313-submit@debbugs.gnu.org id=B72313.17220637187889 (code B ref 72313); Sat, 27 Jul 2024 07:02:02 +0000 Original-Received: (at 72313) by debbugs.gnu.org; 27 Jul 2024 07:01:58 +0000 Original-Received: from localhost ([127.0.0.1]:40411 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sXbRF-00022v-Q7 for submit@debbugs.gnu.org; Sat, 27 Jul 2024 03:01:58 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:30481) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sXbRC-000223-P9 for 72313@debbugs.gnu.org; Sat, 27 Jul 2024 03:01:56 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6D76C440775; Sat, 27 Jul 2024 03:01:38 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1722063696; bh=5OqhF1NhtTwBJtKYDzYxF0/SgRXumw8y9Fg/3HBkJT4=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Q9dBBTmwB8cdkedM5cg5VFSjut4LoO1Qd7cQx5XVODLwyc1hTDuqusuPhGpNf0kN3 q3ruO8sV6Kxc6rDQ9SxcxM76SiVMISBlh3wBJJvLec74+Bb04egKGlncBzLFfncttP x6U70kTx4JUVdoYj0utUOfsEBELQf7OG5GYMRhbjwJKAyPIh1C6CUvk08tfRMx6EeZ m40d3KNgNB59vaSZq/ODtBYsyJx7juPHKjkU6Ark9r1o5fcdAOfiJ4WHLG/twuWNnd 5rtwQB9NaBoIgQruOyy7XKtF5aHJAQiTSJy7bsYstJkpRiuV1DuWwFhVT9lwj9/cI1 luR6N2kR+y/iw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A542B440439; Sat, 27 Jul 2024 03:01:36 -0400 (EDT) Original-Received: from asado (dyn.144-85-159-142.dsl.vtx.ch [144.85.159.142]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 99AC8120213; Sat, 27 Jul 2024 03:01:35 -0400 (EDT) In-Reply-To: <874j8bx5gr.fsf@gnu.org> (Tassilo Horn's message of "Fri, 26 Jul 2024 22:29:08 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289406 Archived-At: > --8<---------------cut here---------------start------------->8--- > ;; -*- lexical-binding: t; -*- > (eval-when-compile > (require 'cl-lib)) > > (defun foo () > (let ((s (list 'a 'b))) > (cl-pushnew (list 1 2 3) > s > :test (lambda (_a _b) nil)))) > --8<---------------cut here---------------end--------------->8--- (macroexpand-all '(cl-pushnew (list 1 2 3) s :test (lambda (_a _b) nil))) => (setq s (let* ((va (list 1 2 3))) (if (cl-member va s :test #'(lambda (_a _b) nil)) s (cons va s)))) > My assumption is that (eval-when-compile (require 'cl-lib)) should be > fine when using only macros from cl-lib which in turn should expand to > cl-free code, That's not the case here (and a few other places). In the past, I've moved some of this kind of code to `cl-preloaded`, so as to make things easier for programmers (to avoid them having to know which CL macros emit code which calls CL functions (and when)), but there are still cases like above, yes. In practice most complex macros are often best served by emitting code which itself calls helper functions (e.g. `cl-defstruct` used to not call a function but I changed it to call `cl-struct-define`). Stefan