Fix bug with structure keys and polymorphic structs.

Use `match*'
Add test

svn: r14482

original commit: 69a3b7a70f56e01d732491d0fa001fe3c7667868
This commit is contained in:
Sam Tobin-Hochstadt 2009-04-09 23:52:13 +00:00
parent e5d7c897d4
commit 88b15b7219
3 changed files with 21 additions and 5 deletions

View File

@ -0,0 +1,16 @@
#lang typed-scheme
(require scheme/list)
(define-type-alias (ListOf X) (U Empty (Cons X)))
(define-struct: Empty ())
(define-struct: (X) Cons ((first : X) (rest : (ListOf X))))
(: sum ((ListOf Number) -> Number))
(define (sum alon)
(cond
[(Empty? alon) 0]
[else (+ (Cons-first alon)
(sum (Cons-rest alon)))]))
(sum (make-Cons 5 (make-Cons 3 (make-Cons 1 (make-Empty)))))

View File

@ -106,7 +106,7 @@
poly?
pred-id
cert)]
[#:key (gensym)])
[#:key #f #;(gensym)])
;; kw : keyword?
;; ty : Type

View File

@ -114,14 +114,14 @@
;; check-below : (/\ (Result Type -> Result)
;; (Type Type -> Type))
(define (check-below tr1 expected)
(match (list tr1 expected)
[(list (tc-result: t1 te1 ee1) t2)
(match* (tr1 expected)
[((tc-result: t1 te1 ee1) t2)
(unless (subtype t1 t2)
(tc-error/expr "Expected ~a, but got ~a" t2 t1))
(ret expected)]
[(list t1 t2)
[(t1 t2)
(unless (subtype t1 t2)
(tc-error/expr"Expected ~a, but got ~a" t2 t1))
(tc-error/expr "Expected ~a, but got ~a" t2 t1))
expected]))
(define (tc-expr/check form expected)