From 1144015fe3028e62dbe4ae380425ce5aa8ecfdc1 Mon Sep 17 00:00:00 2001 From: Raymond Toy <toy.raymond@gmail.com> Date: Sun, 10 Jan 2021 04:33:03 +0000 Subject: [PATCH] Fix #91: Handle loop destructuring The destructuring shortcut in loop doesn't require all the parts be available. If they're not, each item is replaced by NIL. This is fixed by still using `destructuring-bind`, except we mark everything as optional. --- src/code/loop.lisp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/code/loop.lisp b/src/code/loop.lisp index 8e50390b7..6325f239d 100644 --- a/src/code/loop.lisp +++ b/src/code/loop.lisp @@ -995,7 +995,10 @@ collected result will be returned as the value of the LOOP." (if crocks (let ((*ignores* ())) (declare (special *ignores*)) - `((destructuring-bind ,(subst-gensyms-for-nil (car crocks)) + ;; Destructuring in loop doesn't require that the values be + ;; available. The missing elements are filled with NIL. So, + ;; make everything &optional + `((destructuring-bind (&optional ,@(subst-gensyms-for-nil (car crocks))) ,(cadr crocks) (declare (ignore ,@*ignores*)) ,@(loop-build-destructuring-bindings (cddr crocks) forms)))) -- GitLab