~ chicken-core (chicken-5) 04fb8aa6879e8d7d9cea471563bee7f051aba231
commit 04fb8aa6879e8d7d9cea471563bee7f051aba231
Author: Evan Hanson <evhan@foldling.org>
AuthorDate: Sat Dec 28 19:47:19 2013 +1300
Commit: Peter Bex <peter.bex@xs4all.nl>
CommitDate: Thu Jan 9 21:12:17 2014 +0100
Add null guards and fix empty list rewriting in (pair a b) <-> (list ...) type comparisons
This makes sure type comparisons between (pair ...) and (list ...) forms
don't fall off the end of the list, causing unhelpful errors about
calling cadr/caddr on null.
Signed-off-by: Peter Bex <peter.bex@xs4all.nl>
diff --git a/scrutinizer.scm b/scrutinizer.scm
index 91a8f69b..0cdd4f23 100644
--- a/scrutinizer.scm
+++ b/scrutinizer.scm
@@ -1158,9 +1158,10 @@
(match1 ct1 t2)
#t))) ; inexact match
((list)
- (and (match1 (second t1) (second t2))
+ (and (pair? (cdr t2))
+ (match1 (second t1) (second t2))
(match1 (third t1)
- (if (null? (cdr t2))
+ (if (null? (cddr t2))
'null
`(list ,@(cddr t2))))))
(else #f))))
@@ -1173,8 +1174,9 @@
(match1 t1 ct2)
(and (not exact) (not all))))) ; inexact mode: ok
((list)
- (and (match1 (second t1) (second t2))
- (match1 (if (null? (cdr t1))
+ (and (pair? (cdr t1))
+ (match1 (second t1) (second t2))
+ (match1 (if (null? (cddr t1))
'null
`(list ,@(cddr t1)))
(third t2))))
Trap