From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#12604: 24.2.50; No error when setting read-only defstruct slot Date: Mon, 08 Oct 2012 23:15:30 -0400 Message-ID: References: <39C98324-A281-4DA9-96CD-878280F88DF1@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1349752597 17927 80.91.229.3 (9 Oct 2012 03:16:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 9 Oct 2012 03:16:37 +0000 (UTC) Cc: 12604-done@debbugs.gnu.org To: Ivan Andrus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 09 05:16:44 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TLQJG-0000cO-Rg for geb-bug-gnu-emacs@m.gmane.org; Tue, 09 Oct 2012 05:16:43 +0200 Original-Received: from localhost ([::1]:45723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLQJA-0006uo-Hi for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Oct 2012 23:16:36 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:33551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLQJ7-0006uh-Jr for bug-gnu-emacs@gnu.org; Mon, 08 Oct 2012 23:16:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TLQJ6-0005kY-Dg for bug-gnu-emacs@gnu.org; Mon, 08 Oct 2012 23:16:33 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52453) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TLQJ6-0005is-9z for bug-gnu-emacs@gnu.org; Mon, 08 Oct 2012 23:16:32 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TLQJa-0006Qf-HY for bug-gnu-emacs@gnu.org; Mon, 08 Oct 2012 23:17:02 -0400 Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Tue, 09 Oct 2012 03:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 12604 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 12604@debbugs.gnu.org, monnier@iro.umontreal.ca Original-Received: via spool by 12604-done@debbugs.gnu.org id=D12604.134975257024642 (code D ref 12604); Tue, 09 Oct 2012 03:17:01 +0000 Original-Received: (at 12604-done) by debbugs.gnu.org; 9 Oct 2012 03:16:10 +0000 Original-Received: from localhost ([127.0.0.1]:34469 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TLQIk-0006PP-Fz for submit@debbugs.gnu.org; Mon, 08 Oct 2012 23:16:10 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.182]:15595) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TLQIi-0006PA-0b for 12604-done@debbugs.gnu.org; Mon, 08 Oct 2012 23:16:08 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai0FAG6Zu09FxLQG/2dsb2JhbABEsEiDSYEIghUBAQQBViMFCwsOJhIUGA0kiBwFugmQRAOjM4FYgwU X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="200895940" Original-Received: from 69-196-180-6.dsl.teksavvy.com (HELO pastel.home) ([69.196.180.6]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 08 Oct 2012 23:15:30 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 4AF76594EE; Mon, 8 Oct 2012 23:15:30 -0400 (EDT) In-Reply-To: <39C98324-A281-4DA9-96CD-878280F88DF1@gmail.com> (Ivan Andrus's message of "Mon, 8 Oct 2012 18:54:05 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.50 (gnu/linux) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:65411 Archived-At: > The following Elisp does not raise an error, but it should (and did > e.g. in 24.1). [...] > (predicate nil :read-only t) [...] > (setf (emacs-achievement-predicate bob) t) Very good point, indeed. I installed the patch below which should fix this, Stefan === modified file 'lisp/emacs-lisp/cl-macs.el' --- lisp/emacs-lisp/cl-macs.el 2012-10-06 17:34:57 +0000 +++ lisp/emacs-lisp/cl-macs.el 2012-10-08 20:44:22 +0000 @@ -2324,26 +2324,29 @@ (if (= pos 0) '(car cl-x) `(nth ,pos cl-x)))) forms) (push (cons accessor t) side-eff) - ;; Don't bother defining a setf-expander, since gv-get can use - ;; the compiler macro to get the same result. - ;;(push `(gv-define-setter ,accessor (cl-val cl-x) - ;; ,(if (cadr (memq :read-only (cddr desc))) - ;; `(progn (ignore cl-x cl-val) - ;; (error "%s is a read-only slot" - ;; ',accessor)) + (if (cadr (memq :read-only (cddr desc))) + (push `(gv-define-expander ,accessor + (lambda (_cl-do _cl-x) + (error "%s is a read-only slot" ',accessor))) + forms) + ;; For normal slots, we don't need to define a setf-expander, + ;; since gv-get can use the compiler macro to get the + ;; same result. + ;; (push `(gv-define-setter ,accessor (cl-val cl-x) ;; ;; If cl is loaded only for compilation, ;; ;; the call to cl--struct-setf-expander would ;; ;; cause a warning because it may not be ;; ;; defined at run time. Suppress that warning. - ;; `(progn + ;; (progn ;; (declare-function ;; cl--struct-setf-expander "cl-macs" ;; (x name accessor pred-form pos)) ;; (cl--struct-setf-expander ;; cl-val cl-x ',name ',accessor ;; ,(and pred-check `',pred-check) - ;; ,pos)))) + ;; ,pos))) ;; forms) + ) (if print-auto (nconc print-func (list `(princ ,(format " %s" slot) cl-s)