From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#47552: 27.1; cl-defstruct field names matching read-only variables -> bad code Date: Sun, 04 Apr 2021 18:59:36 -0400 Message-ID: References: <87wntlyhn9.fsf@rfc20.org> <87y2dxerd8.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11329"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Matt Armstrong , 47552@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Apr 05 01:00:25 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1lTBjE-0002oD-V0 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Apr 2021 01:00:25 +0200 Original-Received: from localhost ([::1]:54358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lTBjB-0001Y7-LC for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 04 Apr 2021 19:00:21 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:55248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lTBis-0001Xo-Ot for bug-gnu-emacs@gnu.org; Sun, 04 Apr 2021 19:00:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lTBis-0003V2-H6 for bug-gnu-emacs@gnu.org; Sun, 04 Apr 2021 19:00:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lTBis-0003NQ-Et for bug-gnu-emacs@gnu.org; Sun, 04 Apr 2021 19:00:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Apr 2021 23:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47552 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: fixed Original-Received: via spool by 47552-submit@debbugs.gnu.org id=B47552.161757718612933 (code B ref 47552); Sun, 04 Apr 2021 23:00:02 +0000 Original-Received: (at 47552) by debbugs.gnu.org; 4 Apr 2021 22:59:46 +0000 Original-Received: from localhost ([127.0.0.1]:36606 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lTBib-0003MW-PY for submit@debbugs.gnu.org; Sun, 04 Apr 2021 18:59:45 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:19330) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lTBia-0003MI-1t for 47552@debbugs.gnu.org; Sun, 04 Apr 2021 18:59:44 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0BE5D4415E5; Sun, 4 Apr 2021 18:59:39 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id A576144096A; Sun, 4 Apr 2021 18:59:37 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1617577177; bh=5YpO06UNpFBXwRJ2upGHVhoPZYeLmJ6wa03DOSks7r4=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=IGKsdJjK9DfrslgbQwNnYMbVauR4Hty+mQF3EQ4dJ4z0TO7cq1z3gb5uxM+qdQdyh 18xFViFkkI2uG5lg0vyw3Qsldg81/8bPbDbUvqQdw4TnjAVv/MMj8baRUTUYpoHrbI 6lPzpMy7Y0Rv1w1ixwjylDz06zc7J+XYSs+3FvyzdlkZVzxGd3mu+VYJ+9tog1Ctpk HbI8NI8+G6kR/EAsx2vS25/TzeAGfH10E5P1H+Inud6SKxBGVvY8SbteuwQvhuMJme okwXhinfPROjrYznIw2ebD/Tc3xrz1a7Zf0poAvHsJd6cHWwVX9nexGzMkS1QnmDa/ Lkj4Fwi9R1RlQ== Original-Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id BE2761203B2; Sun, 4 Apr 2021 18:59:36 -0400 (EDT) In-Reply-To: <87y2dxerd8.fsf@gnus.org> (Lars Ingebrigtsen's message of "Sun, 04 Apr 2021 22:17:55 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:203570 Archived-At: >> The issue is related to the generated code for `make-a', which boils >> down to let binding gcs-done to nil: >> >> (let ((gcs-done))) >> >> Eval the above to get the same error. >> >> Perhaps the code generated for the make- functions should use >> make-symbol or gensym instead? Or a fixed series of field0...fieldN >> symbols? Why risk potentially binding dynamic vars? > > Using a gensym seems like an obvious solution to me, but perhaps Stefan > has an opinion here (added to the CCs). I'm pretty sure that's the right solution, *but* I don't think it's obvious how to get there: `cl-defstruct` defines the constructor using `cl-defsubst` and its `&key` arguments, so the `:gcs-gone` keyword argument inevitably maps to a `gcs-done` variable by definition of how `&key` is supposed to work. So I suspect that in order to fix it, we'd need to stop using `&key`, or to use a more sophisticated version (which I think we'd have to implement first) which lets you specify separately the keyword and the matching variable name (and then make sure that the inlining optimizations still work for it). Stefan