diff options
author | David Thompson <dthompson2@worcester.edu> | 2023-01-07 15:34:28 -0500 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2023-06-08 08:14:41 -0400 |
commit | 2c006b1517eb929c797efb350a15581cf7336f02 (patch) | |
tree | 3eb982268c1c1a382c8c736909d0001a0eae0b93 | |
parent | 75206940a98f7487da8a0398ab5de12fbafe3a71 (diff) |
Fix begin/let.
-rw-r--r-- | infer2.scm | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -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) ...) |