[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/dash f9e6602ac9: Fix -each-while on improper lists
From: |
ELPA Syncer |
Subject: |
[elpa] externals/dash f9e6602ac9: Fix -each-while on improper lists |
Date: |
Thu, 2 Jun 2022 17:57:27 -0400 (EDT) |
branch: externals/dash
commit f9e6602ac9966b74a5ba6e3d332535543c84f4d5
Author: Basil L. Contovounesios <contovob@tcd.ie>
Commit: Basil L. Contovounesios <contovob@tcd.ie>
Fix -each-while on improper lists
* NEWS.md (2.19.2): Announce regression fix.
* dash.el (--each-while): Evaluate predicate before continuing list
traversal.
* dev/examples.el (-take, -drop, -take-while, -drop-while)
(-each-while): Extend tests.
Fixes #393.
---
NEWS.md | 7 +++++++
dash.el | 4 ++--
dev/examples.el | 27 +++++++++++++++++++++++----
3 files changed, 32 insertions(+), 6 deletions(-)
diff --git a/NEWS.md b/NEWS.md
index 2a813f2843..5dbb24bb26 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -6,6 +6,13 @@ See the end of the file for license conditions.
## Change log
+### From 2.19.1 to 2.19.2
+
+#### Fixes
+
+- Fixed a regression from `2.18` in `-take` that caused it to
+ prematurely signal an error on improper lists (#393).
+
### From 2.19.0 to 2.19.1
#### Fixes
diff --git a/dash.el b/dash.el
index 746b15a267..efc4da665b 100644
--- a/dash.el
+++ b/dash.el
@@ -112,8 +112,8 @@ This is the anaphoric counterpart to `-each-while'."
(,i 0)
,elt it it-index)
(ignore it it-index)
- (while (and ,l (setq ,elt (pop ,l) it ,elt it-index ,i) ,pred)
- (setq it ,elt it-index ,i ,i (1+ ,i))
+ (while (and ,l (setq ,elt (car-safe ,l) it ,elt it-index ,i) ,pred)
+ (setq it ,elt it-index ,i ,i (1+ ,i) ,l (cdr ,l))
,@body))))
(defun -each-while (list pred fn)
diff --git a/dev/examples.el b/dev/examples.el
index 783b518ba7..501e205c6f 100644
--- a/dev/examples.el
+++ b/dev/examples.el
@@ -277,10 +277,15 @@ new list."
(-take 3 '(1 2 3 4 5)) => '(1 2 3)
(-take 17 '(1 2 3 4 5)) => '(1 2 3 4 5)
(-take 0 '(1 2 3 4 5)) => '()
- (-take 0 ()) => ()
(-take -1 ()) => ()
- (-take -1 '(1)) => ()
+ (-take 0 ()) => ()
(-take 1 ()) => ()
+ (-take -1 '(1)) => ()
+ (-take 0 '(1)) => ()
+ (-take 1 '(1)) => '(1)
+ (-take -1 '(1 . 2)) => ()
+ (-take 0 '(1 . 2)) => ()
+ (-take 1 '(1 . 2)) => '(1)
(let ((l (list 1 2))) (eq (-take 3 l) l)) => nil)
(defexamples -take-last
@@ -298,10 +303,15 @@ new list."
(-drop 3 '(1 2 3 4 5)) => '(4 5)
(-drop 17 '(1 2 3 4 5)) => '()
(-drop 0 '(1 2 3 4 5)) => '(1 2 3 4 5)
- (-drop 0 ()) => ()
(-drop -1 ()) => ()
- (-drop -1 '(1)) => '(1)
+ (-drop 0 ()) => ()
(-drop 1 ()) => ()
+ (-drop -1 '(1)) => '(1)
+ (-drop 0 '(1)) => '(1)
+ (-drop 1 '(1)) => ()
+ (-drop -1 '(1 . 2)) => '(1 . 2)
+ (-drop 0 '(1 . 2)) => '(1 . 2)
+ (-drop 1 '(1 . 2)) => 2
(let ((l (list 1 2))) (setcar (-drop 1 l) 0) l) => '(1 0)
(let ((l (list 1 2))) (eq (-drop 0 l) l)) => t)
@@ -323,8 +333,11 @@ new list."
(--take-while t ()) => ()
(--take-while nil ()) => ()
(--take-while nil '(1)) => ()
+ (--take-while nil '(1 . 2)) => ()
(--take-while t '(1)) => '(1)
(--take-while t '(1 2)) => '(1 2)
+ (--take-while (< it-index 0) '(1 . 2)) => ()
+ (--take-while (< it-index 1) '(1 . 2)) => '(1)
(let ((l (list 1 2))) (eq (--take-while t l) l)) => nil)
(defexamples -drop-while
@@ -335,8 +348,11 @@ new list."
(--drop-while nil ()) => ()
(--drop-while nil '(1)) => '(1)
(--drop-while nil '(1 2)) => '(1 2)
+ (--drop-while nil '(1 . 2)) => '(1 . 2)
(--drop-while t '(1)) => ()
(--drop-while t '(1 2)) => ()
+ (--drop-while (< it-index 0) '(1 . 2)) => '(1 . 2)
+ (--drop-while (< it-index 1) '(1 . 2)) => 2
(let ((l (list t 2))) (setcar (-drop-while #'booleanp l) 0) l) => '(t 0)
(let ((l (list 1 2))) (eq (--drop-while nil l) l)) => t)
@@ -1748,6 +1764,9 @@ or readability."
(let (s) (--each-while '(1) t (setq s it)) s) => 1
(let (s) (--each-while '(1) nil (setq s it)) s) => nil
(let (s) (--each-while '(1) (setq it t) (setq s it)) s) => 1
+ (let (s) (--each-while '(1 . 2) nil (setq s it)) s) => nil
+ (let (s) (--each-while '(1 . 2) (< it-index 0) (setq s it)) s) => nil
+ (let (s) (--each-while '(1 . 2) (< it-index 1) (setq s it)) s) => 1
(--each-while '(1) t t) => nil)
(defexamples -each-indexed
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/dash f9e6602ac9: Fix -each-while on improper lists,
ELPA Syncer <=