projects
/
scheme.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix typechecking with bindings
[scheme.git]
/
typecheck.scm
diff --git
a/typecheck.scm
b/typecheck.scm
index b3466751fdf7f4161963d3904c13f970b8798a76..f6d7c86465f4869043b3d2fcb9560e42603258d7 100644
(file)
--- a/
typecheck.scm
+++ b/
typecheck.scm
@@
-194,10
+194,14
@@
(define (get-bindings product-types pattern)
(define (go product-type product)
(define (get-bindings product-types pattern)
(define (go product-type product)
-
(case (ast-type x
)
+
(case (ast-type product
)
['var (list (cons product product-type))]
; an inner pattern match
['var (list (cons product product-type))]
; an inner pattern match
- ['app (get-bindings product-type product)]))
+ ['app (let* ([inner-sum (car product)]
+ [inner-sums (cdr (assoc product-type dls))]
+ [inner-product-types (cdr (assoc inner-sum inner-sums))])
+ (get-bindings inner-product-types product))]
+ [else '()]))
(flat-map go product-types (cdr pattern)))
(flat-map go product-types (cdr pattern)))
@@
-211,6
+215,7
@@
(let* ([names (cdr pattern)]
[product-types (cdr sum)]
[new-env (append (get-bindings product-types pattern) env)])
(let* ([names (cdr pattern)]
[product-types (cdr sum)]
[new-env (append (get-bindings product-types pattern) env)])
+
(check dls new-env expr)))]
; pattern match with binding and no constructor
['var (check dls (env-insert env pattern switch-type) expr)]
(check dls new-env expr)))]
; pattern match with binding and no constructor
['var (check dls (env-insert env pattern switch-type) expr)]