>From b8d6270d340a6cdda66d317eb97c4be011dba0c5 Mon Sep 17 00:00:00 2001 From: Evan Hanson Date: Sat, 28 Dec 2013 19:47:19 +1300 Subject: [PATCH 1/3] 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. --- scrutinizer.scm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scrutinizer.scm b/scrutinizer.scm index 91a8f69..0cdd4f2 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)))) -- 1.7.10.4