From unknown Mon Aug 18 04:36:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8631: since lexical merge, byte compiler does not know defmethod defines a function Resent-From: Glenn Morris Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 06 May 2011 17:50:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 8631 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 8631@debbugs.gnu.org X-Debbugs-Original-To: submit@debbugs.gnu.org Received: via spool by submit@debbugs.gnu.org id=B.13047041465653 (code B ref -1); Fri, 06 May 2011 17:50:03 +0000 Received: (at submit) by debbugs.gnu.org; 6 May 2011 17:49:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QIP9F-0001T8-QO for submit@debbugs.gnu.org; Fri, 06 May 2011 13:49:06 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QIP9E-0001Sg-Jo for submit@debbugs.gnu.org; Fri, 06 May 2011 13:49:04 -0400 Received: from localhost ([127.0.0.1]:60157) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QIP99-0006JV-B1; Fri, 06 May 2011 13:48:59 -0400 From: Glenn Morris X-Spook: csim undercover Cocaine Nazi Roswell War on Terrorism X-Ran: %#wNnX%84!s$(Vrv5$/g7ii|8&_)lS5WDV-P_^ User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.3 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) Package: emacs Version: 24.0.50 Since the lexical branch was merged (ie r103798), the byte compiler does not understand that eieio's defmethod defines a function. Eg: emacs -Q -batch -f batch-byte-compile cedet/srecode/dictionary.el In end of data: dictionary.el:712:1:Warning: the following functions are not known to be defined: srecode-dictionary-add-template-table,[...] From unknown Mon Aug 18 04:36:07 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.427 (Entity 5.427) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Glenn Morris Subject: bug#8631: closed (Re: bug#8631: since lexical merge, byte compiler does not know defmethod defines a function) Message-ID: References: X-Gnu-PR-Message: they-closed 8631 X-Gnu-PR-Package: emacs Reply-To: 8631@debbugs.gnu.org Date: Sat, 07 May 2011 04:08:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1304741282-29808-1" This is a multi-part message in MIME format... ------------=_1304741282-29808-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #8631: since lexical merge, byte compiler does not know defmethod defines a= function which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 8631@debbugs.gnu.org. --=20 8631: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D8631 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1304741282-29808-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 8631-done) by debbugs.gnu.org; 7 May 2011 04:07:30 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QIYni-0007k2-5E for submit@debbugs.gnu.org; Sat, 07 May 2011 00:07:30 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QIYng-0007jp-5m for 8631-done@debbugs.gnu.org; Sat, 07 May 2011 00:07:28 -0400 Received: from 121-249-126-200.fibertel.com.ar ([200.126.249.121]:51225 helo=ceviche.home) by fencepost.gnu.org with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QIYnZ-0002Rl-0b; Sat, 07 May 2011 00:07:21 -0400 Received: by ceviche.home (Postfix, from userid 20848) id BAE91664BA; Sat, 7 May 2011 01:07:17 -0300 (ART) From: Stefan Monnier To: Glenn Morris Subject: Re: bug#8631: since lexical merge, byte compiler does not know defmethod defines a function Message-ID: References: Date: Sat, 07 May 2011 01:07:17 -0300 In-Reply-To: (Glenn Morris's message of "Fri, 06 May 2011 13:48:58 -0400") 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: -6.0 (------) X-Debbugs-Envelope-To: 8631-done Cc: "Eric M. Ludlam" , 8631-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.0 (------) > Since the lexical branch was merged (ie r103798), the byte compiler does > not understand that eieio's defmethod defines a function. > Eg: > emacs -Q -batch -f batch-byte-compile cedet/srecode/dictionary.el > In end of data: > dictionary.el:712:1:Warning: the following functions are not known to be > defined: srecode-dictionary-add-template-table,[...] Should be fixed now, thanks to the patch below, Stefan === modified file 'lisp/emacs-lisp/bytecomp.el' --- lisp/emacs-lisp/bytecomp.el 2011-04-15 12:30:15 +0000 +++ lisp/emacs-lisp/bytecomp.el 2011-05-07 03:24:05 +0000 @@ -4173,6 +4173,7 @@ ;; Compile normally, but deal with warnings for the function being defined. (put 'defalias 'byte-hunk-handler 'byte-compile-file-form-defalias) +;; Used for eieio--defalias as well. (defun byte-compile-file-form-defalias (form) (if (and (consp (cdr form)) (consp (nth 1 form)) (eq (car (nth 1 form)) 'quote) === modified file 'lisp/emacs-lisp/eieio.el' --- lisp/emacs-lisp/eieio.el 2011-05-05 03:42:09 +0000 +++ lisp/emacs-lisp/eieio.el 2011-05-07 03:56:24 +0000 @@ -420,6 +420,7 @@ (load-library (car (cdr (symbol-function cname)))))) (defun eieio-defclass (cname superclasses slots options-and-doc) + ;; FIXME: Most of this should be moved to the `defclass' macro. "Define CNAME as a new subclass of SUPERCLASSES. SLOTS are the slots residing in that class definition, and options or documentation OPTIONS-AND-DOC is the toplevel documentation for this class. @@ -1139,6 +1140,17 @@ ;;; CLOS methods and generics ;; + +(put 'eieio--defalias 'byte-hunk-handler + #'byte-compile-file-form-defalias) ;;(get 'defalias 'byte-hunk-handler) +(defun eieio--defalias (name body) + "Like `defalias', but with less side-effects. +More specifically, it has no side-effects at all when the new function +definition is the same (`eq') as the old one." + (unless (and (fboundp name) + (eq (symbol-function name) body)) + (defalias name body))) + (defmacro defgeneric (method args &optional doc-string) "Create a generic function METHOD. DOC-STRING is the base documentation for this class. A generic @@ -1147,7 +1160,21 @@ `defgeneric' for you. With this implementation the ARGS are currently ignored. You can use `defgeneric' to apply specialized top level documentation to a method." - `(eieio-defgeneric (quote ,method) ,doc-string)) + `(eieio--defalias ',method + (eieio--defgeneric-init-form ',method ,doc-string))) + +(defun eieio--defgeneric-init-form (method doc-string) + "Form to use for the initial definition of a generic." + (cond + ((or (not (fboundp method)) + (eq 'autoload (car-safe (symbol-function method)))) + ;; Make sure the method tables are installed. + (eieiomt-install method) + ;; Construct the actual body of this function. + (eieio-defgeneric-form method doc-string)) + ((generic-p method) (symbol-function method)) ;Leave it as-is. + (t (error "You cannot create a generic/method over an existing symbol: %s" + method)))) (defun eieio-defgeneric-form (method doc-string) "The lambda form that would be used as the function defined on METHOD. @@ -1237,26 +1264,6 @@ (cdr entry) )))) -(defun eieio-defgeneric (method doc-string) - "Engine part to `defgeneric' macro defining METHOD with DOC-STRING." - (if (and (fboundp method) (not (generic-p method)) - (or (byte-code-function-p (symbol-function method)) - (not (eq 'autoload (car (symbol-function method))))) - ) - (error "You cannot create a generic/method over an existing symbol: %s" - method)) - ;; Don't do this over and over. - (unless (fboundp 'method) - ;; This defun tells emacs where the first definition of this - ;; method is defined. - `(defun ,method nil) - ;; Make sure the method tables are installed. - (eieiomt-install method) - ;; Apply the actual body of this function. - (fset method (eieio-defgeneric-form method doc-string)) - ;; Return the method - 'method)) - (defun eieio-unbind-method-implementations (method) "Make the generic method METHOD have no implementations. It will leave the original generic function in place, @@ -1292,12 +1299,17 @@ (let* ((key (if (keywordp (car args)) (pop args))) (params (car args)) (arg1 (car params)) - (class (if (consp arg1) (nth 1 arg1)))) - `(eieio--defmethod ',method ',key ',class - (lambda ,(if (consp arg1) + (args (if (consp arg1) (cons (car arg1) (cdr params)) - params) - ,@(cdr args))))) + params)) + (class (if (consp arg1) (nth 1 arg1))) + (code `(lambda ,args ,@(cdr args)))) + `(progn + ;; Make sure there is a generic and the byte-compiler sees it. + (defgeneric ,method ,args + ,(or (documentation code) + (format "Generically created method `%s'." method))) + (eieio--defmethod ',method ',key ',class ',code)))) (defun eieio--defmethod (method kind argclass code) "Work part of the `defmethod' macro defining METHOD with ARGS." @@ -1317,11 +1329,11 @@ method-static) ;; Primary key (t method-primary)))) - ;; make sure there is a generic - (eieio-defgeneric - method - (or (documentation code) - (format "Generically created method `%s'." method))) + ;; Make sure there is a generic (when called from defclass). + (eieio--defalias + method (eieio--defgeneric-init-form + method (or (documentation code) + (format "Generically created method `%s'." method)))) ;; create symbol for property to bind to. If the first arg is of ;; the form (varname vartype) and `vartype' is a class, then ;; that class will be the type symbol. If not, then it will fall ------------=_1304741282-29808-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 6 May 2011 17:49:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QIP9F-0001T8-QO for submit@debbugs.gnu.org; Fri, 06 May 2011 13:49:06 -0400 Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QIP9E-0001Sg-Jo for submit@debbugs.gnu.org; Fri, 06 May 2011 13:49:04 -0400 Received: from localhost ([127.0.0.1]:60157) by fencepost.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QIP99-0006JV-B1; Fri, 06 May 2011 13:48:59 -0400 From: Glenn Morris To: submit@debbugs.gnu.org Subject: since lexical merge, byte compiler does not know defmethod defines a function X-Spook: csim undercover Cocaine Nazi Roswell War on Terrorism X-Ran: %#wNnX%84!s$(Vrv5$/g7ii|8&_)lS5WDV-P_^ User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Score: -6.3 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.3 (------) Package: emacs Version: 24.0.50 Since the lexical branch was merged (ie r103798), the byte compiler does not understand that eieio's defmethod defines a function. Eg: emacs -Q -batch -f batch-byte-compile cedet/srecode/dictionary.el In end of data: dictionary.el:712:1:Warning: the following functions are not known to be defined: srecode-dictionary-add-template-table,[...] ------------=_1304741282-29808-1-- From unknown Mon Aug 18 04:36:07 2025 X-Loop: help-debbugs@gnu.org Subject: bug#8631: since lexical merge, byte compiler does not know defmethod defines a function In-Reply-To: Resent-From: Andy Moreton Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 07 May 2011 13:02:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8631 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.130477326613179 (code B ref -1); Sat, 07 May 2011 13:02:01 +0000 Received: (at submit) by debbugs.gnu.org; 7 May 2011 13:01:06 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QIh85-0003QW-Vn for submit@debbugs.gnu.org; Sat, 07 May 2011 09:01:06 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QIh83-0003Q2-QQ for submit@debbugs.gnu.org; Sat, 07 May 2011 09:01:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QIh7y-00054P-5X for submit@debbugs.gnu.org; Sat, 07 May 2011 09:00:58 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_RP_MATCHES_RCVD, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:58556) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QIh7y-00054L-40 for submit@debbugs.gnu.org; Sat, 07 May 2011 09:00:58 -0400 Received: from eggs.gnu.org ([140.186.70.92]:50922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QIh7x-0006fl-BF for bug-gnu-emacs@gnu.org; Sat, 07 May 2011 09:00:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QIh7w-000548-EI for bug-gnu-emacs@gnu.org; Sat, 07 May 2011 09:00:57 -0400 Received: from lo.gmane.org ([80.91.229.12]:56344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QIh7w-000544-8p for bug-gnu-emacs@gnu.org; Sat, 07 May 2011 09:00:56 -0400 Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1QIh7u-0006sS-Qk for bug-gnu-emacs@gnu.org; Sat, 07 May 2011 15:00:54 +0200 Received: from 82-69-64-228.dsl.in-addr.zen.co.uk ([82.69.64.228]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 07 May 2011 15:00:54 +0200 Received: from andrewjmoreton by 82-69-64-228.dsl.in-addr.zen.co.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 07 May 2011 15:00:54 +0200 X-Injected-Via-Gmane: http://gmane.org/ From: Andy Moreton Date: Sat, 07 May 2011 14:00:36 +0100 Lines: 36 Message-ID: <82wri2zmvf.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: 82-69-64-228.dsl.in-addr.zen.co.uk User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (windows-nt) Cancel-Lock: sha1:eu0+wbOp1vcSBIyUcn5MtM66C5s= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.9 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) On Sat 07 May 2011, Stefan Monnier wrote: >> Since the lexical branch was merged (ie r103798), the byte compiler does >> not understand that eieio's defmethod defines a function. > >> Eg: > >> emacs -Q -batch -f batch-byte-compile cedet/srecode/dictionary.el > >> In end of data: >> dictionary.el:712:1:Warning: the following functions are not known to be >> defined: srecode-dictionary-add-template-table,[...] > > Should be fixed now, thanks to the patch below, Hi Stefan, Since you change in revno 104151, I've bootstrapped on winXP at revno 104154. The build output shows some new errors: --8<---------------cut here---------------start------------->8--- Compiling emacs-lisp/eieio-speedbar.el In toplevel form: emacs-lisp/eieio-speedbar.el:96:1:Error: Symbol's value as variable is void: &rest Compiling emacs-lisp/eieio.el Compiling gnus/nnregistry.el In toplevel form: gnus/nnregistry.el:34:1:Error: Symbol's value as variable is void: &rest --8<---------------cut here---------------end--------------->8--- Running gnus in this emacs fails with the same error message at runtime, so I cannot connect to any news servers with it. Could this be related to your changes ? AndyM