diff --git a/scrutinizer.scm b/scrutinizer.scm index a330d4e..af1db17 100644 --- a/scrutinizer.scm +++ b/scrutinizer.scm @@ -850,7 +850,8 @@ ((##core#typecase) (let* ((ts (walk (first subs) e loc #f #f flow ctags)) (trail0 trail) - (typeenv (type-typeenv (car ts)))) + (typeenv (type-typeenv (car ts))) + (te2 #f)) ;; first exp is always a variable so ts must be of length 1 (let loop ((types (cdr params)) (subs (cdr subs))) (cond ((null? types) @@ -862,14 +863,14 @@ (string-intersperse (map (lambda (t) (sprintf "\n ~a" (type-name t))) (cdr params)) ""))) - ((match-types (car types) (car ts) - (append (type-typeenv (car types)) typeenv) - #t) + ((begin + (set! te2 (append (type-typeenv (car types)) typeenv)) + (match-types (car types) (car ts) te2 #t)) ;; drops exp (mutate-node! n (car subs)) (walk n e loc dest tail flow ctags)) (else - (trail-restore trail0 typeenv) + (trail-restore trail0 te2) (loop (cdr types) (cdr subs))))))) ((##core#switch ##core#cond) (bomb "scrutinize: unexpected node class" class)) diff --git a/tests/scrutiny-tests.scm b/tests/scrutiny-tests.scm index ef4e0d9..96757b7 100644 --- a/tests/scrutiny-tests.scm +++ b/tests/scrutiny-tests.scm @@ -311,3 +311,8 @@ (define (append-result-type-nowarn2) (add1 (list-ref l2 1)))) (let ((l3 (append (the (list-of fixnum) '(1 2)) '(x y)))) (define (append-result-type-nowarn3) (add1 (list-ref l3 1)))) + +;; Check the trail is restored from the combined typeenv +(compiler-typecase (list 2 'a) + ((forall (x) (list x x)) 1) + (else #t))