[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/compat 18152ca068 76/84: Fix edge-case of binding nil i
From: |
ELPA Syncer |
Subject: |
[elpa] externals/compat 18152ca068 76/84: Fix edge-case of binding nil in if-let* and related macros |
Date: |
Tue, 3 Jan 2023 08:57:39 -0500 (EST) |
branch: externals/compat
commit 18152ca06805dc93bc9f15e26c5b298323683afb
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Fix edge-case of binding nil in if-let* and related macros
---
compat-25.el | 4 ++--
compat-26.el | 6 +++---
compat-tests.el | 20 ++++++++++++++++++++
3 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/compat-25.el b/compat-25.el
index 54ea191f45..ace517d502 100644
--- a/compat-25.el
+++ b/compat-25.el
@@ -158,7 +158,7 @@ with an old syntax that accepted only one binding."
(last t) list)
(dolist (var spec)
(push `(,(if (cdr var) (car var) empty)
- (and ,last ,(or (cadr var) (car var))))
+ (and ,last ,(if (cdr var) (cadr var) (car var))))
list)
(when (or (cdr var) (consp (car var)))
(setq last (caar list))))
@@ -183,7 +183,7 @@ The variable list SPEC is the same as in `if-let'."
(last t) list)
(dolist (var spec)
(push `(,(if (cdr var) (car var) empty)
- (and ,last ,(or (cadr var) (car var))))
+ (and ,last ,(if (cdr var) (cadr var) (car var))))
list)
(when (or (cdr var) (consp (car var)))
(setq last (caar list))))
diff --git a/compat-26.el b/compat-26.el
index 6df2545cd7..fd87057805 100644
--- a/compat-26.el
+++ b/compat-26.el
@@ -373,7 +373,7 @@ This is like `if-let' but doesn't handle a VARLIST of the
form
(last t) list)
(dolist (var varlist)
(push `(,(if (cdr var) (car var) empty)
- (and ,last ,(or (cadr var) (car var))))
+ (and ,last ,(if (cdr var) (cadr var) (car var))))
list)
(when (or (cdr var) (consp (car var)))
(setq last (caar list))))
@@ -391,7 +391,7 @@ This is like `when-let' but doesn't handle a VARLIST of the
form
(last t) list)
(dolist (var varlist)
(push `(,(if (cdr var) (car var) empty)
- (and ,last ,(or (cadr var) (car var))))
+ (and ,last ,(if (cdr var) (cadr var) (car var))))
list)
(when (or (cdr var) (consp (car var)))
(setq last (caar list))))
@@ -410,7 +410,7 @@ are non-nil, then the result is non-nil."
(last t) list)
(dolist (var varlist)
(push `(,(if (cdr var) (car var) empty)
- (and ,last ,(or (cadr var) (car var))))
+ (and ,last ,(if (cdr var) (cadr var) (car var))))
list)
(when (or (cdr var) (consp (car var)))
(setq last (caar list))))
diff --git a/compat-tests.el b/compat-tests.el
index 38fcc724b9..e19c5905a9 100644
--- a/compat-tests.el
+++ b/compat-tests.el
@@ -1174,6 +1174,12 @@ being compared against."
(ert-deftest compat-if-let* ()
"Check if `compat--if-let*' was implemented properly."
+ (should ;trivial condition
+ (eq (compat--if-let* ((test t)) 'true 'false) 'true))
+ (should ;trivial non-condition
+ (eq (compat--if-let* ((test nil)) 'true 'false) 'false))
+ (should ;non-binding non-condition
+ (eq (compat--if-let* (((ignore))) 'true 'false) 'false))
(should
(compat--if-let*
((x 3)
@@ -1187,6 +1193,14 @@ being compared against."
(ert-deftest compat-if-let ()
"Check if `compat--if-let' was implemented properly."
+ (should ;trivial condition
+ (eq (compat--if-let ((test t)) 'true 'false) 'true))
+ (should ;trivial non-condition
+ (eq (compat--if-let ((test nil)) 'true 'false) 'false))
+ (should ;trivial non-condition
+ (eq (compat--if-let (test nil) 'true 'false) 'false))
+ (should ;non-binding non-condition
+ (eq (compat--if-let (((ignore))) 'true 'false) 'false))
(should (compat--if-let ((e (memq 0 '(1 2 3 0 5 6))))
e))
(should-not (compat--if-let ((e (memq 0 '(1 2 3 5 6)))
@@ -1200,6 +1214,12 @@ being compared against."
(ert-deftest compat-and-let* ()
"Check if `compat--and-let*' was implemented properly."
+ (should ;trivial condition
+ (compat--and-let* ((test t))))
+ (should ;trivial non-condition
+ (not (compat--and-let* ((test nil)))))
+ (should ;non-binding non-condition
+ (not (compat--and-let* (((ignore))))))
(should ;trivial body
(compat--and-let*
((x 3)
- [elpa] externals/compat 8fbc3b6ea6 69/84: Bump to version 28.1.2.2, (continued)
- [elpa] externals/compat 8fbc3b6ea6 69/84: Bump to version 28.1.2.2, ELPA Syncer, 2023/01/03
- [elpa] externals/compat f42ebfaf97 35/84: Use compat--directory-name-p instead of directory-name-p, ELPA Syncer, 2023/01/03
- [elpa] externals/compat b98e7cc868 39/84: Fix gv-expander for compat-alist-get, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 0e4da35d72 46/84: Add functions and macros from keymap.el, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 11c9917215 51/84: Declare alist-get for usage in compat-alist-get, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 145d344d37 45/84: Add prefixed define-key from Emacs 29.1, ELPA Syncer, 2023/01/03
- [elpa] externals/compat faeeebe50b 52/84: Remove unused local variable in file-name-absolute-p, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 97cecbc1c0 54/84: Replace seq-into with concrete implementations in compat-29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 518067a7d6 58/84: Copy edebug specification for and-let* from if-let*, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 8e397fee78 66/84: Ignore all .patch files, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 18152ca068 76/84: Fix edge-case of binding nil in if-let* and related macros,
ELPA Syncer <=
- [elpa] externals/compat bb25d50b6c 78/84: Fix test skip condition for 'compat-ref-define-key', ELPA Syncer, 2023/01/03
- [elpa] externals/compat 043e3d71b5 79/84: Always load compat-29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 62ec50bdd1 83/84: Merge branch 'emacs-29.1', ELPA Syncer, 2023/01/03
- [elpa] externals/compat accc689c7e 20/84: Remove nonsensical file-parent-directory test comment, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 8b3d3ea5c8 32/84: Merge branch 'master' into emacs-29.1, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 5c0c55c20d 47/84: Document missing functionality from compat-29, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 26cf72e36a 49/84: Explicitly denote subr-x functions with :feature, ELPA Syncer, 2023/01/03
- [elpa] externals/compat b4f38aa5ab 55/84: Copy if-let/if-let* definitions into if-let/when-let, ELPA Syncer, 2023/01/03
- [elpa] externals/compat 9e14c2f2df 56/84: Remove realname for if-let, ELPA Syncer, 2023/01/03
- [elpa] externals/compat c96aa66fb4 57/84: Remove realname for if-let*, ELPA Syncer, 2023/01/03