From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#25088: 25.1; feature-unload and reload of cl-defstruct fails Date: Fri, 02 Dec 2016 00:24:04 -0500 Message-ID: <87eg1qhpjf.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1480656258 21666 195.159.176.226 (2 Dec 2016 05:24:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 2 Dec 2016 05:24:18 +0000 (UTC) To: 25088@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Dec 02 06:24:15 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCgKS-0004TI-Ek for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Dec 2016 06:24:12 +0100 Original-Received: from localhost ([::1]:60729 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCgKU-0004Cz-IO for geb-bug-gnu-emacs@m.gmane.org; Fri, 02 Dec 2016 00:24:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCgKM-0004Cg-Nu for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 00:24:08 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCgKI-0005vv-KW for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 00:24:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33950) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cCgKI-0005vh-HA for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 00:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1cCgKI-0000Hn-8v for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 00:24:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2016 05:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 25088 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14806562011047 (code B ref -1); Fri, 02 Dec 2016 05:24:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 2 Dec 2016 05:23:21 +0000 Original-Received: from localhost ([127.0.0.1]:49349 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCgJd-0000Go-7p for submit@debbugs.gnu.org; Fri, 02 Dec 2016 00:23:21 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:60593) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cCgJc-0000Gd-7E for submit@debbugs.gnu.org; Fri, 02 Dec 2016 00:23:20 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCgJW-0005TL-90 for submit@debbugs.gnu.org; Fri, 02 Dec 2016 00:23:15 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:37110) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCgJW-0005TD-6T for submit@debbugs.gnu.org; Fri, 02 Dec 2016 00:23:14 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51553) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCgJV-0004Aq-35 for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 00:23:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCgJR-0005Qk-1c for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 00:23:13 -0500 Original-Received: from mail-io0-x22b.google.com ([2607:f8b0:4001:c06::22b]:35756) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cCgJQ-0005PZ-P5 for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2016 00:23:08 -0500 Original-Received: by mail-io0-x22b.google.com with SMTP id a124so464076741ioe.2 for ; Thu, 01 Dec 2016 21:23:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:mime-version; bh=mqnE4sG/jft0vuxWtA4Icmi4U2Usuh1MY9eLRn82E9c=; b=vy0m3IzkSQj+ze3jBRNPwhldVns4oAMgoCFrRuNGxkt98Q/SoPySX6Yp+EXGIHnZ5O ZdpZoZnEN5OR2k5fWX3mGBYBNY6XUGdSO6nti0E63TLE66mNB3oueO9gL2voo2t8ZwAg NPtFPxNwYzW7nL6Ei1SN0LDN63WWHP0goShUp9/d+tInXrUi16U35hvQQ5+rHgr8p7LV Eys8tyiJbvpeJ44xOpuPEcHVfEdEyPURR/2wU/zKK01v8WWSkY+Zmt+mThygIxHDjjAv aTlHRg4V/79O+JmAAzUX26LwQqa16DDMvnIT6ETIpyHI/UVeISvYrh2PIZXx2kSWt710 lXqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:subject:date:message-id :mime-version; bh=mqnE4sG/jft0vuxWtA4Icmi4U2Usuh1MY9eLRn82E9c=; b=ju0AQROeUkqkuw0QUu22Py7K6rL7oi1ESo3CinNXuIdESyxvNrCAcaLuFmzgSvOSEu d8Z2i4Tt3DaSyiue96Xhx5WNYFxP8GaI/vt82xnevRtWnw6lZCeq0q6RxT/u8Ju/xnzi LChpSR8yMSIqbxD7GbtcD50OwTJbU271gv4RWoxi7sdvP2g1GWmHBaHV0vpQyGpBjzdA g60GM4/3GdirIWiPh0Uo9JCKXhj064DpGVETd1hH/FUMn6jYevcr4OSea/eLaDhaNtWk cL3kWNp5pJX52Tb6MQQwJAsIkWXcJRvxPDT7TG377KOkqRz9ie30nIIEJiYz5r3pgrUe jRkw== X-Gm-Message-State: AKaTC00oj2deBT5rGQ1DRIRBC4Gdk9AxFBQHGOBcP4m90S5DUG4hlZS10L8c7afBQka58w== X-Received: by 10.36.103.200 with SMTP id u191mr1197491itc.8.1480656187035; Thu, 01 Dec 2016 21:23:07 -0800 (PST) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id e202sm1527806ioe.27.2016.12.01.21.23.05 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 01 Dec 2016 21:23:06 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:126386 Archived-At: --=-=-= Content-Type: text/plain tags: patch Running emacs -Q -l bug-struct-reload.el --eval "(unload-feature 'bug-struct-reload)" -l bug-struct-reload.el Where bug-struct-reload.el contains (eval-when-compile (require 'cl-lib)) (cl-defstruct foo f1) (provide 'bug-struct-reload) Shows in *Messages* the following error Unexpected element (define-type . foo) in load-history Compiler-macro error for foo-p: (void-function foo-p--cmacro) [2 times] This is because cl-defstruct defines the field accessors before the predicate. After calling `feature-unload', the `macro-compiler' symbol property remains on the predicate even though the function itself is undefined. Then when reloading, the compiler tries to call the predicate's compiler-macro to inline it in the accessor function, and fails to find the definition. Since this is a regression in 25.1, I'd like to apply the following patch to emacs-25, which simply puts the predicate definition before the accessor functions. --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=v1-0001-Define-struct-predicate-before-acccesors.patch Content-Description: patch >From d6285c44150fc9f6d0d3d6dadcd272bae3c498e5 Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Fri, 2 Dec 2016 00:03:57 -0500 Subject: [PATCH v1] Define struct predicate before acccesors The accessor functions use the predicate function, which causes problems when reloading after unload-feature: the compiler-macro property is still present on the predicate symbol, and the compiler fails to find the definition when trying to inline it into the accessor function. * lisp/emacs-lisp/cl-macs.el (cl-defstruct): Move predicate definition before field accessor definitions. --- lisp/emacs-lisp/cl-macs.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index c51ed9d..b3a60b1 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -2687,6 +2687,14 @@ cl-defstruct (= safety 1)) (cons 'and (cl-cdddr pred-form)) `(,predicate cl-x)))) + (when pred-form + (push `(cl-defsubst ,predicate (cl-x) + (declare (side-effect-free error-free)) + ,(if (eq (car pred-form) 'and) + (append pred-form '(t)) + `(and ,pred-form t))) + forms) + (push `(put ',name 'cl-deftype-satisfies ',predicate) forms)) (let ((pos 0) (descp descs)) (while descp (let* ((desc (pop descp)) @@ -2741,14 +2749,6 @@ cl-defstruct (setq pos (1+ pos)))) (setq slots (nreverse slots) defaults (nreverse defaults)) - (when pred-form - (push `(cl-defsubst ,predicate (cl-x) - (declare (side-effect-free error-free)) - ,(if (eq (car pred-form) 'and) - (append pred-form '(t)) - `(and ,pred-form t))) - forms) - (push `(put ',name 'cl-deftype-satisfies ',predicate) forms)) (and copier (push `(defalias ',copier #'copy-sequence) forms)) (if constructor -- 2.9.3 --=-=-=--