diff options
author | Noam Postavsky <npostavs@gmail.com> | 2020-04-30 18:55:40 -0400 |
---|---|---|
committer | Noam Postavsky <npostavs@gmail.com> | 2020-05-07 08:23:56 -0400 |
commit | ddc8020327604b92e7e830708933f62a22f48f62 (patch) | |
tree | cfe881705093a9c4c1e726e4909a57abaf59ddf2 /lisp/emacs-lisp | |
parent | de7158598fcd5440c0180ff6f83052c29e490bcd (diff) | |
download | emacs-ddc8020327604b92e7e830708933f62a22f48f62.tar.gz emacs-ddc8020327604b92e7e830708933f62a22f48f62.tar.bz2 emacs-ddc8020327604b92e7e830708933f62a22f48f62.zip |
Don't increment array index in cl-loop twice (Bug#40727)
* lisp/emacs-lisp/cl-macs.el (cl--parse-loop-clause): Put the temp-idx
increment in cl--loop-body, leaving just the side-effect free testing
of the index for both cl--loop-body and cl--loop-conditions.
* test/lisp/emacs-lisp/cl-macs-tests.el (cl-macs-loop-and-arrays):
Extend test to cover this case.
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/cl-macs.el | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index fef8786b599..3317c580028 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -1320,8 +1320,9 @@ For more details, see Info node `(cl)Loop Facility'. (temp-idx (make-symbol "--cl-idx--"))) (push (list temp-vec (pop cl--loop-args)) loop-for-bindings) (push (list temp-idx -1) loop-for-bindings) + (push `(setq ,temp-idx (1+ ,temp-idx)) cl--loop-body) (cl--push-clause-loop-body - `(< (setq ,temp-idx (1+ ,temp-idx)) (length ,temp-vec))) + `(< ,temp-idx (length ,temp-vec))) (if (eq word 'across-ref) (push (list var `(aref ,temp-vec ,temp-idx)) cl--loop-symbol-macs) |