>From 8ecd82832c24548cdef560402c1b048b36406295 Mon Sep 17 00:00:00 2001 From: megane Date: Sun, 2 Dec 2018 18:23:44 +0200 Subject: [PATCH] Fix renaming issue with typevars The 'subst' in simplify-type was not checking what it was renaming so bad things happened as the new test case shows. * scrutinizer.scm (simplify-type): No need to call subst as the typevars are renamed during walking (the "(assq t typeenv) =>" case). * tests/typematch-tests.scm: Add test Signed-off-by: Evan Hanson --- scrutinizer.scm | 9 +-------- tests/typematch-tests.scm | 3 +++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/scrutinizer.scm b/scrutinizer.scm index bbc3b5a9..840cda3d 100644 --- a/scrutinizer.scm +++ b/scrutinizer.scm @@ -1213,13 +1213,6 @@ (let ((typeenv '()) ; ((VAR1 . NEWVAR1) ...) (constraints '()) ; ((VAR1 TYPE1) ...) (used '())) - (define (subst x) - (cond ((symbol? x) - (cond ((assq x typeenv) => cdr) - (else x))) - ((pair? x) - (cons (subst (car x)) (subst (cdr x)))) - (else x))) (define (simplify t) ;;(dd "simplify/rec: ~s" t) (call/cc @@ -1351,7 +1344,7 @@ (list v (simplify (cadr c))))) (else v))))) typeenv) - ,(subst t2)))) + ,t2))) (dd "simplify: ~a -> ~a" t t2) t2))) diff --git a/tests/typematch-tests.scm b/tests/typematch-tests.scm index 97b83289..821ef731 100644 --- a/tests/typematch-tests.scm +++ b/tests/typematch-tests.scm @@ -399,6 +399,9 @@ (length a) ; refine (or pair null) with list (= (list-of *)) (infer list a)) +(compiler-typecase (the (list (struct foo) symbol) (the 'a 1)) + ;; The tv "foo" and "foo" in struct should have no relation + ((forall (foo) (list (struct foo) foo)) 'ok)) (assert (compiler-typecase 1 -- 2.11.0