chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] [PATH] scrutinzer: Fix another renaming issue


From: megane
Subject: [Chicken-hackers] [PATH] scrutinzer: Fix another renaming issue
Date: Sun, 02 Dec 2018 18:25:47 +0200
User-agent: mu4e 1.0; emacs 25.1.1

Hello,

Here's fix to another renaming issue. This is unrelated to the other one
I just sent. Patch message should explain everything.

Regards

>From 849bd565dcf03b1fd03f3426ff4f65810b0dda29 Mon Sep 17 00:00:00 2001
From: megane <address@hidden>
Date: Sun, 2 Dec 2018 18:23:44 +0200
Subject: [PATCH] * scrutinizer.scm: 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
---
 scrutinizer.scm           | 9 +--------
 tests/typematch-tests.scm | 3 +++
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/scrutinizer.scm b/scrutinizer.scm
index bbc3b5a..840cda3 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 97b8328..821ef73 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.7.4


reply via email to

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