From 2c006b1517eb929c797efb350a15581cf7336f02 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Sat, 7 Jan 2023 15:34:28 -0500 Subject: Fix begin/let. --- infer2.scm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/infer2.scm b/infer2.scm index 18f8ef2..b7211c7 100644 --- a/infer2.scm +++ b/infer2.scm @@ -143,13 +143,12 @@ vals*)) (define env* (append (map cons vars val-types) env)) (define body* (annotate-exp body env*)) - (pk 'body* body*) - (make-texp (texp-types body*) + (make-texp (map (lambda (_type) (fresh-type-variable)) (texp-types body*)) `(let ,(map list vars vals*) ,body*))) (define-matcher (annotate:begin ('begin exps ... last) env) (define last* (annotate-exp last env)) - (make-texp (texp-types last*) + (make-texp (map (lambda (_type) (fresh-type-variable)) (texp-types last*)) `(begin ,@(map (lambda (exp) (annotate-exp exp env)) exps) ,last*))) @@ -222,12 +221,15 @@ (define-matcher (constrain:let ((? type? types) ...) ('let (((? symbol? vars) (? texp? vals)) ...) (? texp? body))) - (append (program-constraints body) - (append-map program-constraints vals))) + (cons (constrain types (texp-types body)) + (append (program-constraints body) + (append-map program-constraints vals)))) (define-matcher (constrain:begin ((? type? types) ...) - ('begin (? texp? texps) ...)) - (append-map program-constraints texps)) + ('begin (? texp? texps) ... (? texp? last))) + (cons (constrain types (texp-types last)) + (append (program-constraints last) + (append-map program-constraints texps)))) (define-matcher (constrain:lambda ((? procedure-type? type)) ('lambda ((? symbol? args) ...) -- cgit v1.2.3