Subject: Re: bug#79396: 30.1; cl-copy-list can error but is declared as error-free

From: Mattias Engdegård <[email-masked]>
Date: Sun, 7 Sep 2025 11:05:06 +0200

mail--- dixit:

> cl-copy-list can error if given a value that isn't nil or a cons cell,
> like (cl-copy-list 3), as expected. However, the function was declared
> (side-effect-free error-free), which contradicts this.

The error-free declaration is clearly wrong. Sorry about that, and thanks for reporting it.

However, the CL spec doesn't really mandate a specific behaviour when the argument is not a list, so one alternative would be to just have it return its argument in that case. It's attractive because the behaviour would be very clean:

  (cl-copy-list (A . B)) = (cons A (cl-copy-list B))
  (cl-copy-list ATOM) = ATOM

In a way, an atom is the base case of a dotted list.
After such a change, cl-copy-list might qualify as error-free. It will still diverge if given a circular list though.

(CC:ing Stefan in case he has a preference.)