mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 14:30:50 -08:00
Consider the expansion of `cl-loop' with a `for' clause and more
than one internal variables, X, Y, processed in parallel.
Each step updates X and Y right after update the loop variable, K; if
either X or Y depend on K, then some forms of the body are
evaluated with the wrong K (Bug#29799).
For instance, consider the following code:
(cl-loop for k below 2
for x = (progn (message "k = %d" k) 1)
and y = 1)
This code should show in *Messages*:
k = 0
k = 1
Instead, the code shows:
k = 0
k = 1
k = 2
To prevent this we must ensure that the loop condition is still
satisfied right after update the loop variable.
In the macro expansion of the example above, right after:
(setq k (+ k 1))
evaluate the rest of the body forms iif the condition
(< k 2)
is still valid.
* lisp/emacs-lisp/cl-macs.el (cl--loop-guard-cond): New variable.
(cl--parse-loop-clause): Set it non-nil if the loop contains
a for/as clause.
(cl-loop): After update the loop variable, evaluate the remaining of
the body forms just if the loop condition is still valid (Bug#29799).
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-for-as-equals-and):
New test.
|
||
|---|---|---|
| .. | ||
| edebug-resources | ||
| eieio-tests | ||
| faceup-resources | ||
| faceup-tests | ||
| package-resources | ||
| testcover-resources | ||
| benchmark-tests.el | ||
| bytecomp-tests.el | ||
| checkdoc-tests.el | ||
| cl-extra-tests.el | ||
| cl-generic-tests.el | ||
| cl-lib-tests.el | ||
| cl-macs-tests.el | ||
| cl-print-tests.el | ||
| cl-seq-tests.el | ||
| derived-tests.el | ||
| edebug-tests.el | ||
| ert-tests.el | ||
| ert-x-tests.el | ||
| generator-tests.el | ||
| gv-tests.el | ||
| let-alist-tests.el | ||
| lisp-mode-tests.el | ||
| lisp-tests.el | ||
| map-tests.el | ||
| nadvice-tests.el | ||
| package-tests.el | ||
| pcase-tests.el | ||
| pp-tests.el | ||
| regexp-opt-tests.el | ||
| ring-tests.el | ||
| rmc-tests.el | ||
| rx-tests.el | ||
| seq-tests.el | ||
| subr-x-tests.el | ||
| tabulated-list-test.el | ||
| testcover-tests.el | ||
| thunk-tests.el | ||
| timer-tests.el | ||