summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2023-01-07 15:34:28 -0500
committerDavid Thompson <dthompson2@worcester.edu>2023-06-08 08:14:41 -0400
commit2c006b1517eb929c797efb350a15581cf7336f02 (patch)
tree3eb982268c1c1a382c8c736909d0001a0eae0b93
parent75206940a98f7487da8a0398ab5de12fbafe3a71 (diff)
Fix begin/let.
-rw-r--r--infer2.scm16
1 files 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) ...)