From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.devel Subject: Re: master 5ee4209f30: cl-typep: Emit warning when using a type not known to be a type Date: Sat, 11 Jun 2022 15:30:33 +0300 Message-ID: <87sfobo00m.fsf@tcd.ie> References: <165448824864.24232.14098817740649938997@vcs2.savannah.gnu.org> <20220606040409.08719C009A8@vcs2.savannah.gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30110"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: Stefan Monnier , Jonas Bernoulli To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 11 14:32:00 2022 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 1o00HY-0007aB-DJ for ged-emacs-devel@m.gmane-mx.org; Sat, 11 Jun 2022 14:32:00 +0200 Original-Received: from localhost ([::1]:50436 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o00HX-0001Tw-2J for ged-emacs-devel@m.gmane-mx.org; Sat, 11 Jun 2022 08:31:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58906) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o00GL-0000nO-1Q for emacs-devel@gnu.org; Sat, 11 Jun 2022 08:30:45 -0400 Original-Received: from mail-ed1-x52c.google.com ([2a00:1450:4864:20::52c]:40838) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o00GF-0006um-LS for emacs-devel@gnu.org; Sat, 11 Jun 2022 08:30:44 -0400 Original-Received: by mail-ed1-x52c.google.com with SMTP id w27so1932260edl.7 for ; Sat, 11 Jun 2022 05:30:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd.ie; s=google21; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=mJessSg8Mm1eJGPxVOdRTryHqvdGPNPLvhifhZX8Rzo=; b=gbKfcvFCY04G0L4ko1NKyzuBZAHphk+Xj0F4QZvX54nAUybaA6YTaXMRq3suJ7l7L1 W5/4m3UtIUQ/QJLbyKwkVB3GgiSoWgxV4VIt//B5ZHR/4JROiSOADbhdm+OS24E1JRUL /tN19GVh6K+l7qqgJiNijX8IdK7UM8nb3aIwY60jbDokpMA5PLwXrI0MDo62yMpOLiXz pAE/OO3LX+9Vhc8uverQWvZKuHmxP3JwlRdL04twb12M2KcLYCXOxS2NsJrjtV9n754I Qc5DB1FP6uNzEK892HAKdijWw595nhFLAJK4d3vYknMqWDVFMvJs4P7CaFHZYtfB2gR+ PCwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=mJessSg8Mm1eJGPxVOdRTryHqvdGPNPLvhifhZX8Rzo=; b=GobsKQyQ5oTQt1yXJQoyPrQdnVol4gI0Eg+ptFG2JwRAsQMkGEQQgc74ZFzbitfn2z LK4gbBvNuk5H1z7/1XjzES6UFWutEgaWcSdcq/y1xB7kQtMuDSFisTFuBrXEor4AYjo1 acwF0BftaNbn+O7ruyfbiD40AaeG8KYxYzF6/YgLftl52vSg7rw4rvPTisGU66QFRsQa j6oRC6p69bC+kSA9Wd7jl14OTr6hKmE4GLvbGShraR4eGWmTwvAlAaxrLztKehgCTR3c uLgKX6Xxd0Yqxt8zVrJUbir9qi20MWQnZysn+sWY7iY4UNXamcMUCsbKxxwo2VeHPt0p LWmg== X-Gm-Message-State: AOAM530V/fYuhNysPkF833KjLZk6p1My2GK4fhB3yZ40vuqWjGlFsRpJ 56GnYKWbNgO+/0nFGSdj0clxZIdepkYReA== X-Google-Smtp-Source: ABdhPJzSbRuPRWkS+KnI3U35LuuZZAeTDuR57dNWSmLw9CEgfH1RkveQUNltYI/qfi92oVxaD7juoQ== X-Received: by 2002:a05:6402:23a3:b0:42e:251a:c963 with SMTP id j35-20020a05640223a300b0042e251ac963mr51086905eda.173.1654950636755; Sat, 11 Jun 2022 05:30:36 -0700 (PDT) Original-Received: from localhost ([2a02:587:322b:6f5e:dc92:136a:a7c4:dc8c]) by smtp.gmail.com with ESMTPSA id i2-20020a170906444200b006fed8dfcf78sm957751ejp.225.2022.06.11.05.30.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jun 2022 05:30:35 -0700 (PDT) In-Reply-To: <20220606040409.08719C009A8@vcs2.savannah.gnu.org> (Stefan Monnier's message of "Mon, 6 Jun 2022 00:04:08 -0400 (EDT)") Received-SPF: pass client-ip=2a00:1450:4864:20::52c; envelope-from=contovob@tcd.ie; helo=mail-ed1-x52c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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:291032 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier [2022-06-06 00:04 -0400] wrote: > branch: master > commit 5ee4209f307fdf8cde9775539c9596d29edccd6d > Author: Stefan Monnier > Commit: Stefan Monnier > > cl-typep: Emit warning when using a type not known to be a type > > `cl-typep` has used a heuristic that if there's a `-p` function, > then can be used as a type. This made sense in the past where > most types were not officially declared to be (cl-)types, but nowadays > this just encourages abuses such as using `cl-typecase` with > "types" like `fbound`. It's also a problem for EIEIO objects, where > for historical reasons `-p` tests if the object is of type > exactly `` whereas (cl-typep OBJ ) should instead test > if OBJ is a *subtype* of ``. > > So we change `cl-typep` to emit a warning whenever this "-p" heuristic > is used, to discourage abuses, encourage the use of explicit > `cl-deftype` declarations, and try and detect some misuses of > `-p` for EIEIO objects. [...] I think this change gave rise to the following 'error: success' message: 0. emacs -Q -l cl-lib 1. (cl-typep (make-process :name "" :command '("true")) 'process) 2. C-j -| Warning: Unknown type: process => t In practice, I see this when using Magit with Forge[0]; see the attached backtrace which I obtained by adding a call to backtrace before macroexp-warn-and-return in cl-typep. Is the following a sufficient fix? --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=cl-typep.diff diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index ada4f0344d..24a4cec4e2 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -3423,6 +3423,7 @@ cl--macroexp-fboundp (null . null) (overlay . overlayp) (real . numberp) + (process . processp) (sequence . sequencep) (subr . subrp) (string . stringp) --=-=-= Content-Type: text/plain Thanks, -- Basil [0]: https://magit.vc/manual/forge/ --=-=-= Content-Type: text/plain Content-Disposition: attachment; filename=forge-backtrace.txt Content-Transfer-Encoding: quoted-printable backtrace() cl-typep(# process) eieio--perform-slot-validation(process #) eieio--validate-slot-value(#s(eieio--class :name forge-database :docstrin= g nil :parents (#s(eieio--class :name emacsql-sqlite-connection :docstring = nil :parents (#s(eieio--class :name emacsql-connection :docstring nil :pare= nts nil :slots [#s(cl-slot-descriptor :name process :initform ... :type pro= cess :props nil) #s(cl-slot-descriptor :name log-buffer :initform nil :type= ... :props ...) #s(cl-slot-descriptor :name finalizer :initform ... :type = t :props ...)] :index-table # :children = (emacsql-sqlite-connection) :initarg-tuples ((:process . process) (:log-buf= fer . log-buffer)) :class-slots [#s(cl-slot-descriptor :name types :initfor= m nil :type t :props ...)] :class-allocation-values [nil] :default-object-c= ache # :options (:custo= m-groups nil (:documentation "A connection to a SQL database.") :abstract t= )) #s(eieio--class :name emacsql-protocol-mixin :docstring nil :parents nil= :slots [] :index-table # :children (ema= csql-sqlite-connection) :initarg-tuples nil :class-slots [] :class-allocati= on-values [] :default-object-cache # :options (:custom-groups nil (:documentation "A mixin= for back-ends following the EmacSQL protoc...") :abstract t))) :slots [#s(= cl-slot-descriptor :name process :initform 'eieio--unbound :type process :p= rops nil) #s(cl-slot-descriptor :name log-buffer :initform nil :type (or nu= ll buffer) :props ((:documentation . "Output log (debug)."))) #s(cl-slot-de= scriptor :name finalizer :initform 'eieio--unbound :type t :props ((:docume= ntation . "Object returned from `make-finalizer'."))) #s(cl-slot-descriptor= :name file :initform 'eieio--unbound :type (or null string) :props ((:docu= mentation . "Database file name.")))] :index-table # :children (forge-database) :initarg-tuples ((:process . proces= s) (:log-buffer . log-buffer) (:file . file)) :class-slots [#s(cl-slot-desc= riptor :name types :initform '(... ... ... ...) :type t :props ((:documenta= tion . "Maps EmacSQL types to SQL types.")))] :class-allocation-values [((i= nteger "INTEGER") (float "REAL") (object "TEXT") (nil nil))] :default-objec= t-cache #= :options (:custom-groups nil (:documentation "A connection to a SQLite dat= abase."))) #s(eieio--class :name closql-database :docstring nil :parents ni= l :slots [] :index-table # :children (fo= rge-database) :initarg-tuples nil :class-slots [#s(cl-slot-descriptor :name= object-class :initform 'eieio--unbound :type t :props nil)] :class-allocat= ion-values [eieio--unbound] :default-object-cache # :options (:custom-groups nil :abstract t))) :slots [= #s(cl-slot-descriptor :name process :initform 'eieio--unbound :type process= :props nil) #s(cl-slot-descriptor :name log-buffer :initform nil :type (or= null buffer) :props ((:documentation . "Output log (debug)."))) #s(cl-slot= -descriptor :name finalizer :initform 'eieio--unbound :type t :props ((:doc= umentation . "Object returned from `make-finalizer'."))) #s(cl-slot-descrip= tor :name file :initform 'eieio--unbound :type (or null string) :props ((:d= ocumentation . "Database file name.")))] :index-table # :children nil :initarg-tuples ((:process . process) (:log-b= uffer . log-buffer) (:file . file)) :class-slots [#s(cl-slot-descriptor :na= me object-class :initform 'forge-repository :type t :props nil) #s(cl-slot-= descriptor :name types :initform '((integer "INTEGER") (float "REAL") (obje= ct "TEXT") (nil nil)) :type t :props ((:documentation . "Maps EmacSQL types= to SQL types.")))] :class-allocation-values [forge-repository ((integer "I= NTEGER") (float "REAL") (object "TEXT") (nil nil))] :default-object-cache #= :options (:custom-groups nil))= 1 # process) #f(compiled-function (obj slot value) "Do the work for the macro `oset'.\= nFills in OBJ's SLOT with VALUE." #)(# process #) eieio-oset--closql-oset(#f(compiled-function (obj slot value) "Do the wor= k for the macro `oset'.\nFills in OBJ's SLOT with VALUE." #) # process #) apply(eieio-oset--closql-oset #f(compiled-function (obj slot value) "Do t= he work for the macro `oset'.\nFills in OBJ's SLOT with VALUE." #) (# process= #)) eieio-oset(# process #) #f(compiled-function (# (:fil= e "/home/blc/.emacs.d/index/forge-db.sqlite")) apply(#f(compiled-function=20 #f(compiled-function (&rest args) #)(# (:file "/home/blc/.emacs.d/index/forg= e-db.sqlite")) apply(#f(compiled-function (&rest args) #) #<= forge-database forge-database-155a214261e6> (:file "/home/blc/.emacs.d/inde= x/forge-db.sqlite")) initialize-instance(# (:file = "/home/blc/.emacs.d/index/forge-db.sqlite")) #f(compiled-function (class &rest slots) "Default constructor for CLASS `= eieio-default-superclass'.\nSLOTS are the initialization slots used by `ini= tialize-instance'.\nThis static method is called when an object is construc= ted.\nIt allocates the vector used to represent an EIEIO object, and then\n= calls `initialize-instance' on that object." #= )(forge-database :file "/home/blc/.emacs.d/index/forge-db.sqlite") apply(#f(compiled-function (class &rest slots) "Default constructor for C= LASS `eieio-default-superclass'.\nSLOTS are the initialization slots used b= y `initialize-instance'.\nThis static method is called when an object is co= nstructed.\nIt allocates the vector used to represent an EIEIO object, and = then\ncalls `initialize-instance' on that object." #) forge-database (:file "/home/blc/.emacs.d/index/forge-db.sqlite")) make-instance(forge-database :file "/home/blc/.emacs.d/index/forge-db.sql= ite") #f(compiled-function (class &optional variable file debug) #)(forge-database forge--db-connection "/home/blc/.emacs.d/i= ndex/forge-db.sqlite" t) apply(#f(compiled-function (class &optional variable file debug) #) forge-database (forge--db-connection "/home/blc/.em= acs.d/index/forge-db.sqlite" t)) closql-db(forge-database forge--db-connection "/home/blc/.emacs.d/index/f= orge-db.sqlite" t) forge-db() forge-sql([:select * :from repository :where (and (=3D forge $s1) (=3D ow= ner $s2) (=3D name $s3))] "github.com" "magit" "magit") #f(compiled-function (&rest rest) "((host owner name) &optional remote de= mand)\n\nReturn the repository identified by HOST, OWNER and NAME." #)(("github.com" "magit" "magit") "upstream" full) apply(#f(compiled-function (&rest rest) "((host owner name) &optional rem= ote demand)\n\nReturn the repository identified by HOST, OWNER and NAME." #= ) ("github.com" "magit" "magit") ("upstream" f= ull)) forge-get-repository(("github.com" "magit" "magit") "upstream" full) #f(compiled-function (url &optional remote demand) "Return the repository= at URL." #)("https://github.com/magit/magit.= git" "upstream" full) apply(#f(compiled-function (url &optional remote demand) "Return the repo= sitory at URL." #) "https://github.com/magit/= magit.git" ("upstream" full)) forge-get-repository("https://github.com/magit/magit.git" "upstream" full) #f(compiled-function (demand &optional remote) "Return the current forge = repository.\n\nIf the `forge-buffer-repository' is non-nil, then return tha= t.\nOtherwise if `forge-buffer-topic' is non-nil, then return the\nreposito= ry for that. Finally if both variables are nil, then\nreturn the forge rep= ository corresponding to the current Git\nrepository, if any." #)(full) apply(#f(compiled-function (demand &optional remote) "Return the current = forge repository.\n\nIf the `forge-buffer-repository' is non-nil, then retu= rn that.\nOtherwise if `forge-buffer-topic' is non-nil, then return the\nre= pository for that. Finally if both variables are nil, then\nreturn the for= ge repository corresponding to the current Git\nrepository, if any." #) full nil) forge-get-repository(full) forge-bug-reference-setup() run-hooks(change-major-mode-after-body-hook special-mode-hook magit-secti= on-mode-hook magit-mode-hook magit-status-mode-hook) apply(run-hooks (change-major-mode-after-body-hook special-mode-hook magi= t-section-mode-hook magit-mode-hook magit-status-mode-hook)) run-mode-hooks(magit-status-mode-hook) magit-status-mode() magit-setup-buffer-internal(magit-status-mode nil ((magit-buffer-diff-arg= s ("--no-ext-diff")) (magit-buffer-diff-files nil) (magit-buffer-log-args (= "-n64" "--show-signature" "-n256" "--decorate")) (magit-buffer-log-files ni= l))) magit-status-setup-buffer("~/.emacs.d/src/magit/") magit-project-status() funcall-interactively(magit-project-status) call-interactively(magit-project-status) project-switch-project("~/.emacs.d/src/magit/") funcall-interactively(project-switch-project "~/.emacs.d/src/magit/") call-interactively(project-switch-project nil nil) command-execute(project-switch-project) --=-=-=--