Add debug macro, and fix check-below to return appropriate values.

This commit is contained in:
Sam Tobin-Hochstadt 2008-06-18 16:52:04 -04:00
parent 3e4e5af03c
commit e77ad12feb
3 changed files with 13 additions and 4 deletions

View File

@ -85,6 +85,8 @@
(match (tc-expr/check e t)
[(tc-result: t) t]))
;; check-below : (/\ (Result Type -> Result)
;; (Type Type -> Type))
(define (check-below tr1 expected)
(match (list tr1 expected)
[(list (tc-result: t1 te1 ee1) t2)
@ -94,7 +96,7 @@
[(list t1 t2)
(unless (subtype t1 t2)
(tc-error/expr"Expected ~a, but got ~a" t2 t1))
(ret expected)]))
expected]))
(define (tc-expr/check form expected)
(parameterize ([current-orig-stx form])

View File

@ -161,7 +161,7 @@
(if (and expected
(= 1 (length (syntax->list formals))))
;; special case for not-case-lambda
(let loop ([expected expected])
(let loop ([expected expected])
(match expected
[(Mu: _ _) (loop (unfold expected))]
[(Function: (list (arr: args ret rest #f _ _)))
@ -171,7 +171,7 @@
(for ([args argss] [ret rets] [rest rests])
(tc/lambda-clause/check (car (syntax->list formals)) (car (syntax->list bodies)) args ret rest))
expected]
[t (let ([t (tc/mono-lambda formals bodies #f)])
[t (let ([t (tc/mono-lambda formals bodies #f)])
(check-below t expected))]))
(let loop ([formals (syntax->list formals)]
[bodies (syntax->list bodies)]

View File

@ -14,7 +14,14 @@
hash-union
in-pairs
in-list-forever
extend)
extend
debug)
(define-syntax-rule (debug args)
(begin (printf "starting ~a~n" 'args)
(let ([e args])
(printf "result was ~a~n" e)
e)))
(define-syntax (with-syntax* stx)
(syntax-case stx ()