>From fd3de2653850806947de6461d3c1db332278e1fc Mon Sep 17 00:00:00 2001 From: Evan Hanson Date: Sat, 16 Aug 2014 16:16:29 +1200 Subject: [PATCH 1/5] Fix list-copy types.db entry to allow any argument type list-copy accepts any argument type (returning non-pair arguments unchanged), so its type should be a -> a. This also means it can be marked pure, and improves the scrutinizer's accuracy on list-copy calls since the argument type can be preserved as the result type. --- tests/typematch-tests.scm | 3 +++ types.db | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/typematch-tests.scm b/tests/typematch-tests.scm index bbd5a3c..6cbcc9a 100644 --- a/tests/typematch-tests.scm +++ b/tests/typematch-tests.scm @@ -263,6 +263,9 @@ (mx fixnum (##sys#vector-ref '#(1 2 3.4) 0)) (mx (vector fixnum float) (vector 1 2.3)) (mx (list fixnum float) (list 1 2.3)) +(mx (list fixnum float) (list-copy (list 1 2.3))) +(mx (pair fixnum float) (list-copy (cons 1 2.3))) +(mx fixnum (list-copy 1)) (: f1 (forall (a) ((list-of a) -> a))) (define (f1 x) (car x)) diff --git a/types.db b/types.db index 2621686..e5c0771 100644 --- a/types.db +++ b/types.db @@ -1924,7 +1924,7 @@ (last (#(procedure #:clean #:enforce) last (pair) *)) (last-pair (#(procedure #:clean #:enforce) last-pair (pair) *)) (length+ (#(procedure #:clean #:enforce) length+ (list) *)) -(list-copy (forall (a) (#(procedure #:clean #:enforce) list-copy ((list-of a)) (list-of a)))) +(list-copy (forall (a) (#(procedure #:pure) list-copy (a) a))) (list-index (forall (a) (#(procedure #:enforce) list-index ((procedure (a #!rest) *) (list-of a) #!rest list) *))) (list-tabulate (forall (a) (#(procedure #:enforce) list-tabulate (fixnum (procedure (fixnum) a)) (list-of a)))) (list= (#(procedure #:clean #:enforce) list= (#!optional (procedure (list list) *) #!rest list) boolean) -- 1.7.10.4