Subject: bug#76573: 30.1; native compilation fails for record inside function

From: Andrea Corallo <[email-masked]>
Date: Fri, 25 Apr 2025 16:47:09 -0400

Lin Jian <[email-masked]> writes:

> Sorry for the late reply.
>
> Andrea Corallo <[email-masked]> writes:
>
>> the compiler is complaining because while the code is trying to create
>> an object of type 'foo-r', this was actually never defined.
>>
>> Typically those user defined objects are defined using higher level
>> constructs like 'cl-defstruct' which takes care of registering the
>> definition into the global state (and defining the creator
>> 'make-foo-r').
>>
>> Why is this code trying to create never defined kind of objects?  Isn't
>> the case that the code in the file being compiled is missing some
>> require to the definition?
>
> I have no idea why some elisp packages use `record' directly instead of
> some higher level functions like `cl-defstruct' since I am not the
> author of those packages.
>
> If using `record' directly is a user error, I would suggest:
> 1. mentioning it in the manual

We can always improve the manual (patches welcome), but the docstring
for 'record' already says:

"(record TYPE &rest SLOTS)

Create a new record.
TYPE is its type as returned by ‘type-of’."

How can somebody expect this machinery to work reliably for a certain
type which was never defined?