From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lawrence Mitchell Newsgroups: gmane.emacs.bugs Subject: bug#9035: 24.0.50; byte-compiler warnings with defstruct and lexical-binding Date: Sat, 09 Jul 2011 14:10:08 +0100 Message-ID: <871uxz7eu2.fsf@ed.ac.uk> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1310222129 3396 80.91.229.12 (9 Jul 2011 14:35:29 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 9 Jul 2011 14:35:29 +0000 (UTC) To: 9035@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jul 09 16:35:25 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QfYcv-0006TI-1c for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Jul 2011 16:35:25 +0200 Original-Received: from localhost ([::1]:40384 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfYcu-0001H7-2Z for geb-bug-gnu-emacs@m.gmane.org; Sat, 09 Jul 2011 10:35:24 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:60802) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfYca-0001F2-B7 for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2011 10:35:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QfYcZ-00041p-0D for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2011 10:35:04 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55456) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfYcY-00041j-Nn for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2011 10:35:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QfYcY-0001hS-4p; Sat, 09 Jul 2011 10:35:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lawrence Mitchell Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 09 Jul 2011 14:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 9035 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13102220686491 (code B ref -1); Sat, 09 Jul 2011 14:35:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 9 Jul 2011 14:34:28 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfYbz-0001ge-IZ for submit@debbugs.gnu.org; Sat, 09 Jul 2011 10:34:27 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QfYbx-0001gQ-32 for submit@debbugs.gnu.org; Sat, 09 Jul 2011 10:34:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QfYbq-0003yK-Cg for submit@debbugs.gnu.org; Sat, 09 Jul 2011 10:34:19 -0400 Original-Received: from lists.gnu.org ([140.186.70.17]:35251) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfYbq-0003yG-5T for submit@debbugs.gnu.org; Sat, 09 Jul 2011 10:34:18 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:60704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfYbo-00018K-Rf for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2011 10:34:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QfYbn-0003y6-H1 for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2011 10:34:16 -0400 Original-Received: from treacle.ucs.ed.ac.uk ([129.215.16.102]:56910) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QfYbj-0003xW-1C for bug-gnu-emacs@gnu.org; Sat, 09 Jul 2011 10:34:15 -0400 Original-Received: from lmtp1.ucs.ed.ac.uk (lmtp1.ucs.ed.ac.uk [129.215.149.64]) by treacle.ucs.ed.ac.uk (8.13.8/8.13.4) with ESMTP id p69EXqW5018341 for ; Sat, 9 Jul 2011 15:33:57 +0100 (BST) Original-Received: from e4300lm (02d8b348.bb.sky.com [2.216.179.72]) (authenticated user=lmitche4 mech=PLAIN bits=0) by lmtp1.ucs.ed.ac.uk (8.13.8/8.13.7) with ESMTP id p69EXoho025553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Sat, 9 Jul 2011 15:33:51 +0100 (BST) X-Edinburgh-Scanned: at treacle.ucs.ed.ac.uk with MIMEDefang 2.60, Sophie, Sophos Anti-Virus, Clam AntiVirus X-Scanned-By: MIMEDefang 2.60 on 129.215.16.102 X-Scanned-By: MIMEDefang 2.52 on 129.215.149.64 X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sat, 09 Jul 2011 10:35:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:48334 Archived-At: In files with lexical-binding set to t, structure definitions with :read-only slots lead to a byte-compiler warning about the unused variable cl-x. To reproduce, byte-compile a file consisting of: ;; -*- lexical-binding: t -*- (eval-when-compile (require 'cl)) (defstruct foo (name nil :read-only t)) This is due to the setf-method that is produced when expanding the defstruct form: (define-setf-method ... (cl-x) (error (format "%s is a read-only slot" ...))) The following patch fixes the problem by changing the setf-method to: (define-setf-method ... (cl-x) (progn (ignore cl-x) (error (format "%s is a read-only slot" ...)))) Commit message/changelog entry Silence byte-compiler warning with :read-only defstruct slots * emacs-lisp/cl-macs.el (defstruct): Ignore argument to setf method if slot is read-only. Patch: diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 2813cc4..6181c6b 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -2389,8 +2389,10 @@ value, that slot cannot be set via `setf'. (push (cons accessor t) side-eff) (push (list 'define-setf-method accessor '(cl-x) (if (cadr (memq :read-only (cddr desc))) - (list 'error (format "%s is a read-only slot" - accessor)) + (list 'progn '(ignore cl-x) + (list 'error + (format "%s is a read-only slot" + 'accessor))) ;; If cl is loaded only for compilation, ;; the call to cl-struct-setf-expander would ;; cause a warning because it may not be