emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/relint b01702dcad 1/2: Cope with circular defalias form


From: ELPA Syncer
Subject: [elpa] externals/relint b01702dcad 1/2: Cope with circular defalias forms
Date: Sun, 13 Mar 2022 11:57:54 -0400 (EDT)

branch: externals/relint
commit b01702dcadac0fbeb4c7050c71fa0e0c4983f7b4
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Mattias EngdegÄrd <mattiase@acm.org>

    Cope with circular defalias forms
    
    Don't recurse infinitely when encountering, for example,
    
    (defalias 'a 'b)
    (defalias 'b 'a)
    
    and so on.
---
 relint.el    |  5 ++++-
 test/5.elisp | 16 ++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/relint.el b/relint.el
index 2967d6b9fd..db63611509 100644
--- a/relint.el
+++ b/relint.el
@@ -1686,7 +1686,10 @@ than just to a surrounding or producing expression."
      ;; (function SYMBOL), to avoid infinite recursion.
      (let ((name (relint--eval-or-nil name-arg))
            (def  (relint--eval-or-nil def-arg)))
-       (when (and name def)
+       (when (and name def
+                  ;; Prevent alias loops.
+                  (not (eq name def))
+                  (not (assq def relint--alias-defs)))
          (push (cons name def) relint--alias-defs))))
     (_
      (let ((index 0))
diff --git a/test/5.elisp b/test/5.elisp
index b18490efa8..931bc1c6a2 100644
--- a/test/5.elisp
+++ b/test/5.elisp
@@ -78,3 +78,19 @@
 (defalias 'test-recursive
   #'(lambda (x)
       (if x (test-recursive (cdr x)) 'ok)))
+
+;; Check for alias loops.
+(defalias 'test-recursive-0 'test-recursive-0)
+(test-recursive-0 'z)
+
+(defalias 'test-recursive-1 'test-recursive-2)
+(defalias 'test-recursive-2 'test-recursive-1)
+(test-recursive-1 'a)
+(test-recursive-2 'b)
+
+(defalias 'test-recursive-3 'test-recursive-4)
+(defalias 'test-recursive-4 'test-recursive-5)
+(defalias 'test-recursive-5 'test-recursive-3)
+(test-recursive-3 'c)
+(test-recursive-4 'd)
+(test-recursive-3 'e)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]