Subject: Re: bug#48219: 27.1.90; CL-LOOP facility fails with hash tables

From: Lars Ingebrigtsen <[email-masked]>
Date: Fri, 01 Jul 2022 14:03:21 +0200

Juan José García Ripoll <[email-masked]> writes:

> (cl-loop
>  for database in nil
>  for aux = (message "databse: %S" database)
>  for entry being the hash-values of database
>  do (message "FOO %S" database))
>
> This code should do nothing, because variable DATABASE runs over an empty list. Yet the macroexpansion of the loop produces code that tries to run over the entries of DATABASE, which is NIL.
>
> (cl--block-wrapper
>  (catch '--cl-block-nil--
>    (let* ((--cl-var-- nil)
> 	  (database nil)
> 	  (aux nil))
>      (cl-block --cl-finish--
>        (maphash (lambda (--cl-var-- entry)
> 		  (or (consp --cl-var--) (cl-return-from --cl-finish-- nil))
> 		  (setq database (car --cl-var--))
> 		  (setq aux (message "databse: %S" database))
> 		  (message "FOO %S" database)
> 		  (setq --cl-var-- (cdr --cl-var--)))
> 		database))
>      nil)))

(I'm going through old bug reports that unfortunately weren't resolved
at the time.)

Yes, that does seem wrong.  I had a brief look at cl--parse-loop-clause,
but this is code I haven't looked at before, and I'm not sure I
understand the control flow here.  Adding Stefan to the CCs; I'm sure he
can tell what should be done immediately.  😀

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