GNU bug report logs - #47552
27.1; cl-defstruct field names matching read-only variables -> bad code

Previous Next

Package: emacs;

Reported by: Matt Armstrong <matt <at> rfc20.org>

Date: Thu, 1 Apr 2021 18:39:01 UTC

Severity: normal

Found in versions 27.1, 28.2

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #8 received at 47552 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Matt Armstrong <matt <at> rfc20.org>
Cc: monnier <at> iro.umontreal.ca, 47552 <at> debbugs.gnu.org
Subject: Re: bug#47552: 27.1; cl-defstruct field names matching read-only
 variables -> bad code
Date: Sun, 04 Apr 2021 22:17:55 +0200
Matt Armstrong <matt <at> rfc20.org> writes:

> I confirmed this in 27 and 28.
>
> Evaluate these forms in *scratch* or M-x ielm:
>
>     (require 'cl-macs)
>     (cl-defstruct a gcs-done)
>     (make-a)
>     *** Eval error ***  Wrong type argument: numberp, nil
>
> Success is expected, as occurs for structs that don't happen to have
> "gcs-done" fields.
>
> 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).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




This bug report was last modified 2 years and 27 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.